You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
Simple O(n) Python solution