You are viewing a single comment's thread. Return to all comments →
I didn't use binary search tree but use dictionary for memory. Here is my Python code
t = int(raw_input().strip()) for a0 in xrange(t): m = int(raw_input().strip()) n = int(raw_input().strip()) a = map(int, raw_input().strip().split(' ')) # find matched number cost_map = {} for i, cost in enumerate(a): sunny = cost johnny = m - cost if johnny in cost_map.keys(): print cost_map[johnny]+1, i+1 else: cost_map[cost] = i
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 →
I didn't use binary search tree but use dictionary for memory. Here is my Python code