You are viewing a single comment's thread. Return to all comments →
it is broken in js :(
const [_, length, rawArr] = input.split('\n'); const arr = rawArr.split(' ').sort((a, b) => a - b); let mid = Math.floor(length / 2); [arr[mid], arr[length - 1]] = [arr[length - 1], arr[mid]] let left = mid + 1; let right = length - 2; while (left < right) { [arr[left], arr[right]] = [arr[right], arr[left]]; left++; right--; } const str = arr.join(' '); const strTrim = str.trim(); console.log(strTrim);
Seems like cookies are disabled on this browser, please enable them to open this website
Zig Zag Sequence
You are viewing a single comment's thread. Return to all comments →
it is broken in js :(