Ah I was so close, I got an O(n) * 2 looking at the whole array twice and setting the difference as map key, and the current value as value; I like your solution much better!
@mscofield99253 жыл бұрын
Best explanation I have seen so far
@Courtney-yk2be2 жыл бұрын
Great explanation. Thank you for sharing!!
@jingkangloh77102 жыл бұрын
why is there a need for map.set(num[i], i); ? does it help with updating the 'diff' in the loop?
@geoffreylee17802 жыл бұрын
it need to store the pair of (key and indice) for future loop comparison
@nikithanikki3398 Жыл бұрын
you're explaining so well. would you please continue the series? 🥲it's very helpful ✨really like the way you explained the problem