이것저것 공부 기록하기

[HackerRank]Search - Ice Cream Parlor(Python3) 본문

Algorithm/HackerRank

[HackerRank]Search - Ice Cream Parlor(Python3)

얍욥얍 2021. 2. 1. 16:18

 

 

 

Ice Cream Parlor | HackerRank

Help Sunny and Johnny spend all their money during each trip to the Ice Cream Parlor.

www.hackerrank.com

 

문제 풀이

그냥 이중 for문으로 간단하게 풀린다.

def icecreamParlor(m, arr):
    for i in range(len(arr)):
        for j in range(i, len(arr)):
            if arr[i] + arr[j] == m and i != j:
                return i+1, j+1

반응형
Comments