Ice Cream Parlor

  • + 0 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