HardPro challengeJavaScriptTypeScript

Drag & Drop Reorder

ReactArraysPatterns

Implement solve(items, fromIndex, toIndex) that reorders array.
Removes item at fromIndex and inserts at toIndex (after removal).

Sample tests

Test #1Move first to last
Input: [["a","b","c"],0,2]
Output: ["b","c","a"]
Test #2Move last to first
Input: [["a","b","c"],2,0]
Output: ["c","a","b"]
Test #3Same position
Input: [["a","b","c"],1,1]
Output: ["a","b","c"]
Test #4Move b to end
Input: [["a","b","c","d"],1,3]
Output: ["a","c","d","b"]
Test #5Single item
Input: [[1],0,0]
Output: [1]