-
[프로그래머스] 최댓값과 최솟값Engineering WIKI/Programmers 2022. 5. 17. 15:28
코딩테스트 연습 - 최댓값과 최솟값
문자열 s에는 공백으로 구분된 숫자들이 저장되어 있습니다. str에 나타나는 숫자 중 최소값과 최대값을 찾아 이를 "(최소값) (최대값)"형태의 문자열을 반환하는 함수, solution을 완성하세요. 예를
programmers.co.kr
내풀이
def solution(s): answer = '' s = s.split(" ") s = list(map(int, s)) min_value = min(s) max_value = max(s) answer = f"{min_value} {max_value}" return answer
다른방법 1
def solution(s): s = list(map(int,s.split())) return str(min(s)) + " " + str(max(s))
'Engineering WIKI > Programmers' 카테고리의 다른 글
[프로그래머스] JadenCase 문자열 만들기 (0) 2022.05.23 [프로그래머스] 행렬의 곱셉 (0) 2022.05.23 [프로그래머스] 피보나치 수 (0) 2022.05.17 [프로그래머스] 최솟값 만들기 (0) 2022.05.17 [프로그래머스] 카펫 (0) 2022.05.17 [프로그래머스] H-Index (정렬) (0) 2022.05.13 [프로그래머스] 행렬 테두리 회전하기 (0) 2022.05.10 [프로그래머스] 타겟넘버 (0) 2022.05.06