REC

프로그래머스 Lv.1: K번째 수 - Python 풀이 본문

Algorithm

프로그래머스 Lv.1: K번째 수 - Python 풀이

서서리 2025. 1. 25. 23:41
SMALL

오늘의 문제

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

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

내 풀이

def solution(array, commands):
    answer = []
    for command in commands: # commands 하나씩 살펴보자~
        i = command[0]
        j = command[1]
        k = command[2]
        tmp = array[i-1: j] # array의 i번째 수부터 j번째 수까지 slice
        tmp.sort() # 정렬
        answer.append(tmp[k-1]) # k번째 수를 answer에 append
    return answer

 

문카클의 코테 스터디 4주차. 이번 주는 정렬입니다!

맛보기로 Level 1 풀어봤는데 너무 쉬워서 머쓱... 설명은 주석으로 대체할게요

LIST