Loading...
Loading...
Loading...
Customers join a delivery batch in the order they sign up. A late customer must be placed at a given position. Insert them there so that everyone after them moves one place back, then print the list and its size.
[a, b, c], then Size: <size>.Example
Input
3 Asha Ravi Meena 1 Kabir
Output
[Asha, Kabir, Ravi, Meena] Size: 4
Kabir takes index 1; Ravi and Meena move back.
Try the problem first. Open one hint at a time.
add(index, item) inserts and moves the later items; set(index, item) would replace instead.
The index n is allowed for add(index, item): it means "at the end".
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor