You are viewing a single comment's thread. Return to all comments →
Simple JavaScript solution
arr.reduce((p,c,i) => { if (i === 0) return p; if (c < p.curr[i - 1]) { p.curr.splice(i, 1); p.curr.splice(p.curr.findIndex((e) => e > c), 0, c); } p.answer.push(p.curr.join(' ')); return p; }, {curr: [...arr], answer: []}).answer.join('\n');
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
Simple JavaScript solution