nums in reverse order. The original array must not be modified.Reverse Array
L2 Easy Arrays & Hashing
Concept
Walking an array backwards with a stride loop is a standard trick. The reversed copy keeps the original untouched.
Return a new array containing the values of
Examples
▸ nums = [1, 2, 3, 4]
→ [4, 3, 2, 1]
▸ nums = []
→ []
▸ nums = [9]
→ [9]
Progressive Hints
Hint 1 · Nudge
Read the array backwards and fill a new one front to back.
Hint 2 · Plan
Create an empty result array. Walk the indexes from the last down to the first, appending each element. Return the result.
Hint 3 · Approach
result = []. For i from the last index down to 0: append nums[i]. Return result.
All hints are out. Take a breath and give it a shot.
Output
// Run your code to see the output here.