728x90
Programmers
배열 비교하기
https://school.programmers.co.kr/learn/courses/30/lessons/181856
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제
코드
<풀이1>
- 노가다 풀이
def solution(arr1, arr2):
answer = 0
if len(arr1) > len(arr2):
answer = 1
elif len(arr1) < len(arr2):
answer = -1
else:
arr1_result = sum(arr1)
arr2_result = sum(arr2)
if arr1_result > arr2_result:
answer = 1
elif arr1_result < arr2_result:
answer = -1
else:
answer = 0
return answer
Reference
728x90
반응형
'Algorithm > 프로그래머스' 카테고리의 다른 글
[프로그래머스] rny_string - 파이썬 (0) | 2024.03.20 |
---|---|
[프로그래머스] 길이에 따른 연산 - 파이썬 (0) | 2024.03.20 |
[프로그래머스] 가까운 1 찾기 - 파이썬 (0) | 2024.03.20 |
[프로그래머스] 카운트 다운 - 파이썬 (0) | 2024.03.20 |
[프로그래머스] 글자 지우기 - 파이썬 (0) | 2024.03.20 |