IT 개발자_S

해커랭크 Brithday Chocolate 본문

IT/알고리즘_Python

해커랭크 Brithday Chocolate

Soso12 2020. 3. 22. 23:26
반응형

# Complete the birthday function below.

def birthday(s, d, m):

    result =0

    for i in range(len(s) -m +1):

        sumNum =0

        for j in range(m) :

            sumNum += s[i+j]

        if(sumNum ==d) : 

            result+=1

    return result

 

이중 for 문을 사용하여 

기준점을 구함

반응형

'IT > 알고리즘_Python' 카테고리의 다른 글

해커랭크 The Hurdle Race  (0) 2020.03.31
해커랭크 Picking Numbers  (0) 2020.03.29
해커랭크 Breaking the Records  (0) 2020.03.22
해커랭크 Kangaroo PYTHON  (0) 2020.03.13
해커랭크 Apple and Orange  (0) 2020.03.12
Comments