values and positions. Start with an empty list and walk through the arrays from left to right: at step i, insert values[i] so that it ends up at position positions[i] (0-based), shifting the element at that position and everything after it one place to the right.
Return the list you get after all the inserts. Every position is guaranteed to be valid: at step i it never exceeds the current length of the list.values=[5, 6, 7, 8], positions=[0, 0, 1, 3] → [6, 7, 5, 8]
[5] → 6 at the front: [6, 5] → 7 at position 1: [6, 7, 5] → 8 at the end (position 3): [6, 7, 5, 8].
values=[1, 2, 3], positions=[0, 0, 0] → [3, 2, 1]
Each number goes to the front, so the order comes out reversed.
values=[5, 6, 7, 8], positions=[0, 0, 1, 3]
[6, 7, 5, 8]
Run checks the first 3 tests in your browser. Submit checks all 71 tests on the server, hidden ones included.