Thanks for the video! Great to see different ways and the reasoning. I have submitted a simpler answer and went well for all test cases. function sockMerchant(n, ar) { // sort array let sortedAr = ar.sort(); let pairs = 0; for (let i = 0; i < sortedAr.length - 1; i++){ if (sortedAr[i] == sortedAr[i+1]){ pairs++; i++; } } return pairs }
@mazthespaz12 жыл бұрын
you should worry about the time complexity of the sort especially if you were looking at 2 or 3 million socks
@babyyoda89132 жыл бұрын
Bro can you drop your contact
@yenngoc2653 жыл бұрын
You try to give the video more brightness it will be great if you do
@y_thedreamer953 жыл бұрын
To fix your icons in the terminal, you just have to specify in the vs code settings that you want that font for the terminal as well, I mean the fancy font, maybe Inconsolata or whatever you have used, so that it will recognize the icons.
@avemaria4ajay2 жыл бұрын
const arr = [1,2,3,1]; const s = new Set(); const res = arr.reduce((pre, curr) => { if(s.has(curr)){ s.delete(curr); return ++pre; } s.add(curr); return pre; }, 0); console.log(res)