You are viewing a single comment's thread. Return to all comments →
Hey folks,
My solution in javascript with time complexity Big O of n,
function lonelyinteger(a) { const map = {}; let result = 0; for (let i = 0; i < a.length; i++) { if (a[i] in map) { map[a[i]] = map[a[i]] + 1; } else { map[a[i]] = 1; } } for(const [key,value] of Object.entries(map)){ if(value === 1){ result = key } } return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
Hey folks,
My solution in javascript with time complexity Big O of n,