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])