728x90
[나의 코드]
def solution(absolutes, signs):
for i in range(len(signs)):
if signs[i]==False:
absolutes[i] = -absolutes[i]
else:
pass
return sum(absolutes)
[다른 사람 코드]
def solution(absolutes, signs):
return sum(absolutes if sign else -absolutes for absolutes, sign in zip(absolutes, signs))
728x90
'STUDY > Python' 카테고리의 다른 글
@staticmethod 란? (0) | 2023.04.19 |
---|---|
[프로그래머스] 겹치는 선분의 길이 파이썬 (0) | 2023.04.10 |
[프로그래머스] K의 개수 파이썬 (0) | 2023.04.06 |
[프로그래머스] 2차원으로 만들기 파이썬 (0) | 2023.04.06 |
[deque] 양방향 자료형 - 파이썬 (0) | 2023.04.04 |