Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertArray(arr, N) {
- let result = [], swapIndex = -1;
- for (let i = 0; i < arr.length; i++) {
- swapIndex = arr[(N * (i%N)) + i/N];
- while (swapIndex < i) {
- swapIndex = arr[(N * (swapIndex%N)) + swapIndex/N];
- }
- swap(arr, swapIndex, i);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement