[HackerRank][Python3] Hash Tables: Ice Cream Parlor
2018. 7. 16. 23:42 |
프로그래밍/HackerRank
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])
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Max Array Sum (0) | 2018.07.18 |
---|---|
[HackerRank][Python3] Making Candies (0) | 2018.07.18 |
[HackerRank][Python3] Minimum Time Required (0) | 2018.07.17 |
[HackerRank][Python3] Pairs (0) | 2018.07.17 |
[HackerRank][Python3] Triple sum (0) | 2018.07.16 |
[HackerRank][Python3] Max Min (0) | 2018.07.16 |
[HackerRank][Python3] Greedy Florist (0) | 2018.07.16 |
[HackerRank][Python3] Luck Balance (0) | 2018.07.15 |
최근에 달린 댓글 최근에 달린 댓글