-
프로그래머스 - 음양 더하기 [자바]Algorithms/- 프로그래머스 2022. 1. 30. 22:36
- 문제 링크 : 음양 더하기
정답
class Solution { public int solution(int[] absolutes, boolean[] signs) { int answer = 0; int length = absolutes.length; for(int i = 0; i<length; i++){ int absolute = absolutes[i]; if(signs[i] == false){ answer += absolute * -1; }else{ answer += absolute; } } return answer; } }
분석
- 단순 사칙연산
반응형