[문제 링크] 👇
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
Solution
def solution(absolutes, signs):
answer = 0
for i in range(len(signs)):
if signs[i] == 1:
answer += absolutes[i]
else:
answer -= absolutes[i]
return answer
👩💻 회고
숏코딩 한 거 보니 어나더 레벨
if 문에서 == 1 해줄 필요 없이 그냥 if signs[i] 라고만 해줘도 됐었다. 불필요한 코드 추가..
'프로그래머스 코딩테스트 > Level 1' 카테고리의 다른 글
[Programmers] L1. 부족한 금액 계산하기 (Python) (0) | 2024.10.25 |
---|---|
[Programmers] L1. 내적 (Python) (0) | 2024.10.25 |
Programmers 약수의 합 (Java/Level 1) (0) | 2023.02.09 |
Programmers 서울에서 김서방 찾기 (Python/Level 1) (0) | 2022.08.22 |
Programmers 없는 숫자 더하기 (Python/Level 1) (0) | 2022.07.31 |