프로그래밍/HackerRank
[HackerRank][Python3] Hash Tables: Ice Cream Parlor
snoopybox
2018. 7. 16. 23:42
Problem :
https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem
My Solution :
#!/usr/bin/env python3
def whatFlavors(cost, money):
menu = {}
for i, c in enumerate(cost, 1):
if money - c in menu:
return menu[money-c][0], i
menu.setdefault(c, []).append(i)
t = int(input())
for _ in range(t):
money = int(input())
n = int(input())
cost = list(map(int, input().rstrip().split()))
result = whatFlavors(cost, money)
print(result[0], result[1])