You are viewing a single comment's thread. Return to all comments →
Broken in JS but here is my solution
function processData(input) { const arrStartIndex = input.lastIndexOf('\n'); const finalArr = input.substring(arrStartIndex + 1).split(' '); const sortedArr = finalArr.sort((a, b) => a - b); const middleNumber = (sortedArr.length / 2) const secondHalf = sortedArr.slice(middleNumber) const firstHalf = sortedArr.slice(0, middleNumber) const result= [...firstHalf, ...secondHalf.reverse()].join(' ') return result; }
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 →
Broken in JS but here is my solution