You are viewing a single comment's thread. Return to all comments →
Solution in Python with time complexity O(n)
def icecreamParlor(m, arr): indices = [] prices = {} for i, p in enumerate(arr): compl = m - p if compl in prices: indices = [prices[compl] + 1, i + 1] prices[p] = i print(prices) return sorted(indices)
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
Solution in Python with time complexity O(n)