Your question is Reverse an Array and Duplicate Elements. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Infor OS processes ordered configuration values represented as arrays. Given a mutable integer array nums and an index index, duplicate the element originally stored at index, then reverse the entire resulting array.
The operation must modify nums in place and return the same list object. The duplicated values must remain adjacent after reversal. In other words, first insert a copy immediately after the selected element, then reverse the complete array.
Implement reverse_and_duplicate(nums, index):
nums, a non-empty list of integers, and index, a valid zero-based index in the original list.nums list after duplicating nums[index] and reversing the result.def reverse_and_duplicate(nums, index):