hash tables ice cream parlor hackerrank solution python

Solutions on MaxInterview for hash tables ice cream parlor hackerrank solution python by the best coders in the world

showing results for - "hash tables ice cream parlor hackerrank solution python"
Rafael
01 Feb 2018
1from collections import Counter
2
3def icecreamParlor(m, arr):
4    costs = Counter(arr)
5    half = m/2
6    combos = set()
7    for cost in costs:
8        if (cost!=half and m-cost in costs) or (cost==half and costs[cost]>1):
9            combos.add(cost)
10    for index,cost in enumerate(arr,1):
11        if cost in combos:
12            yield index
13for _ in range(int(input())):
14    m,n = int(input()), int(input())
15    arr = list(map(int,(input().split())))
16    print(*icecreamParlor(m, arr))
17