문제: https://school.programmers.co.kr/learn/courses/30/lessons/12939
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
방법1
def solution(s):
answer = ''
s = s.split(' ')
max, min = -1000000, 1000000
for i in range(len(s)):
if int(s[i]) > int(max):
max = s[i]
if int(s[i]) < int(min):
min = s[i]
answer = str(min) +' ' + str(max)
return answer
방법2
def solution(s):
answer = ''
s = list(map(int,s.split(' ')))
max_num = max(s)
min_num = min(s)
answer = str(min_num) +' ' + str(max_num)
return answer
반응형
'공부 서랍장 > 알고리즘 공부' 카테고리의 다른 글
[프로그래머스] 같은 숫자는 싫어 python (0) | 2022.09.17 |
---|---|
[프로그래머스] 최대공약수와 최대공배수 python (0) | 2022.09.16 |
[프로그래머스] 폰켓몬 python (0) | 2022.09.16 |
[프로그래머스] 시저 암호 python (0) | 2022.09.16 |
[프로그래머스] 내적 python (0) | 2022.09.16 |