You are viewing a single comment's thread. Return to all comments →
I think my solution has O(n) time complexity and O(n) space complexity.
In Python 3 the code would look like this:
def icecreamParlor(money, costs): costs_map = {} for i, cost in enumerate(costs): costs_map[cost] = i for i, cost in enumerate(costs): remaining=money-cost if remaining in costs_map: if costs_map[remaining] != i: return sorted([i+1, costs_map[remaining]+1])
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 think my solution has O(n) time complexity and O(n) space complexity.
In Python 3 the code would look like this: