A queue of customers is stored as a list of names. Write insert_at(queue, index, name) that returns a new list in which name has been placed at position index, pushing later customers back by one. If index is larger than or equal to the length of the queue, the name goes at the very end. The original list must not be modified: one test calls queue_after(queue, index, name), which runs your insert_at and then returns queue itself, so it must come back unchanged.
Examples
Input: queue = ["ana", "bo", "cy"], index = 1, name = "dee"
Output: ["ana", "dee", "bo", "cy"]
Input: queue = ["ana", "bo"], index = 5, name = "eve"
Output: ["ana", "bo", "eve"]
Constraints
0 <= len(queue) <= 50000 <= index <= 10000
Goals
- Copy a list so the original is untouched
- Use insert to place an item at a given index