Problem

Swap arr[i] and arr[i+1]; return new array.

Examples

  • swapAdjacent([1, 2, 3], 0) -> [2, 1, 3]
Compile and test (Ctrl+Enter)