STUDY/Algorithm

[프로그래머스] LEVEL1 나누어떨어지는 숫자 배열, python3

sinawi95 2019. 10. 15. 12:25
728x90

def solution(arr, divisor):
    answer = [] 
    for i in range(len(arr)):
        tmp=arr[i]/divisor
        if tmp==arr[i]//divisor:
            answer.append(arr[i])
    answer.sort()
    if len(answer)==0:
        answer.append(-1)
    return answer