Hash Tables: Ice Cream Parlor

  • + 0 comments

    Simple O(n) Python solution

        index = {}
        for i0, v in enumerate(cost):   # print diff if it exists
            if i1 := index.get(money - v): print(i1, i0 + 1)
            else: index[v] = i0 + 1     # else add value to index