forked from srishilesh/Data-Structure-and-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIcecream_parlor
42 lines (31 loc) · 901 Bytes
/
Icecream_parlor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// https://www.hackerrank.com/challenges/icecream-parlor/problem
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the icecreamParlor function below.
def icecreamParlor(m, arr):
result = []
for idx,val in enumerate(arr):
if(m-val in arr[idx+1:]):
result.append(idx+1)
#print(arr[idx+1:].index(m-val) + idx + 2)
result.append(arr[idx+1:].index(m-val)+idx+2)
break
if(len(result)>0):
return result
else:
return -1
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
t = int(input())
for t_itr in range(t):
m = int(input())
n = int(input())
arr = list(map(int, input().rstrip().split()))
result = icecreamParlor(m, arr)
fptr.write(' '.join(map(str, result)))
fptr.write('\n')
fptr.close()