[프로그래머스] 제일 작은 수 제거하기

단간단간·2024년 5월 3일
0

알고리즘 문제

목록 보기
97/106

문제 링크:

https://school.programmers.co.kr/learn/courses/30/lessons/12935


python

def solution(arr):
    if len(arr) == 1:
        return [-1]
    else:
        idx = arr.index(min(arr))
        return arr[:idx] + arr[idx + 1:]


if __name__ == "__main__":
    result = solution([4, 3, 2, 1])
    print(result)
[4, 3, 2]
profile
simple is best

0개의 댓글