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.
"Sometimes you need to compare lists of number, but sorting each one normally will take too much time. Instead you can use alternative methods to find the differences between each list."
Probably me missing the point... Isn't the quickest method to sort a and b and then do a scan difference between the two lists. You can sort in O(n log n) then scan diff in O(n) whereas if you diff without sorting first you are O(n squared).
Like I say, I may have totally missed the point (or got my times completely wrong). I don't understand the why we are told not to sort each one normally.
Incedently, I did sort a and b before implementing my diff, and it passed.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Missing Numbers (FP)
You are viewing a single comment's thread. Return to all comments →
"Sometimes you need to compare lists of number, but sorting each one normally will take too much time. Instead you can use alternative methods to find the differences between each list."
Probably me missing the point... Isn't the quickest method to sort a and b and then do a scan difference between the two lists. You can sort in O(n log n) then scan diff in O(n) whereas if you diff without sorting first you are O(n squared).
Like I say, I may have totally missed the point (or got my times completely wrong). I don't understand the why we are told not to sort each one normally.
Incedently, I did sort a and b before implementing my diff, and it passed.