Ice Cream Parlor

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