You are viewing a single comment's thread. Return to all comments →
JS, not the most optimal, it parses the costs array n times:
function icecreamParlor(m, arr) { let solution = null; arr.forEach((item, index) => { arr.forEach((item2, index2) => { if (item + item2 === m && index !== index2 && !solution) { solution = [index + 1, index2 + 1]; } }) }) return solution; }
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
JS, not the most optimal, it parses the costs array n times: