We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I used a dictionary in which, all the numbers in the array are the keys - all with value 1 (to signify that this key exists). Now, when I use dict [3] and it returns to me a 1, this means that 3 exists in the array. Using this trick, I was able to make a linear time program (The longest a case took was 0.04s)
So yeah, you're right!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
I used a dictionary in which, all the numbers in the array are the keys - all with value 1 (to signify that this key exists). Now, when I use dict [3] and it returns to me a 1, this means that 3 exists in the array. Using this trick, I was able to make a linear time program (The longest a case took was 0.04s)
So yeah, you're right!