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've passed all test cases except the last one. Here is what I have done: - read an element of a. - decrement the value for the key corresponding to the element. - repeat for all other elements of a. - read an element of b. - increment the value for the key corresponding to the element. - repeat for all other elements of b. - print all the positive values in the map. This works in O(n) time but I get a TLE on the last case. I can't think of a way to optimise this further. Any hints?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Triplets
You are viewing a single comment's thread. Return to all comments →
I've passed all test cases except the last one. Here is what I have done: - read an element of a. - decrement the value for the key corresponding to the element. - repeat for all other elements of a. - read an element of b. - increment the value for the key corresponding to the element. - repeat for all other elements of b. - print all the positive values in the map. This works in O(n) time but I get a TLE on the last case. I can't think of a way to optimise this further. Any hints?