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'll never understand the HackerRank trend of posting solutions in the discussion section let alone uncommented and unexplained solutions.
My thoughts:
* I considered a two-pointer solution but the array isn't pre-sorted so this would require a sort which adds n * log(n) or a custom sort/search
Alternatively, you can use memoisation (collect some info while traversing for later). You need to think about the complement of the current price and available money.
Don't forget that the array isn't unique, just the solution
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
I'll never understand the HackerRank trend of posting solutions in the discussion section let alone uncommented and unexplained solutions.
My thoughts: * I considered a two-pointer solution but the array isn't pre-sorted so this would require a sort which adds n * log(n) or a custom sort/search
Alternatively, you can use memoisation (collect some info while traversing for later). You need to think about the complement of the current price and available money.
Don't forget that the array isn't unique, just the solution