Implement insertAtPosition(arr, index, value), which inserts value at the given index of arr. Existing elements at that index and after shift one position to the right to make space. Modify the array in place and return it.
Input
arr: an array of numbers
index: the position to insert at (0 <= index <= arr.length)
value: the number to insert
Output
The modified array with value inserted at index.
Examples
Example 1
Inputarr = [1, 2, 3, 4, 5], index = 0, value = 3
Output[3, 1, 2, 3, 4, 5]
Example 2
Inputarr = [10, 20], index = 2, value = 2
Output[10, 20, 2]
Constraints
0 <= index <= arr.length
The operation runs in O(n) time.