https://school.programmers.co.kr/learn/courses/30/lessons/42748
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
내가 제출했던 답
def solution(array, commands):
answer = []
for i in range(len(commands)):
answer.append(sorted(array[commands[i][0]-1:commands[i][1]])[commands[i][2]-1])
return answer
람다를 이용한 풀이
def solution(array, commands):
return list(map(lambda x:sorted(array[x[0]-1:x[1]])[x[2]-1], commands))
문제 자체는 어려운 편이 아니지만 람다를 이용하면 훨씬 식이 깔끔해진다.
람다를 더 공부해야겠다..
| [파이썬/python] 프로그래머스 : 성격 유형 검사하기(Lv.1) (0) | 2023.01.16 |
|---|---|
| [파이썬/python] 프로그래머스 : 개인정보 수집 유효기간(Lv.1) (0) | 2023.01.16 |
| [파이썬/python] 프로그래머스 : 크키가 작은 부분 문자열(Lv.1) (0) | 2022.12.23 |
| [파이썬/python] 백준 5800번 : 성적통계 (🥈5) (2) | 2022.11.15 |
| [파이썬/python] 백준 10773번 : 제로 (🥈4) (0) | 2022.11.15 |