웅재의 코딩세상
[프로그래머스] 음양 더하기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> absolutes, vector<bool> signs) {
int answer = 0;
for(int i=0; i<signs.size(); i++){
if(signs[i]==false){
absolutes[i] = (-1)* absolutes[i];
}
answer += absolutes[i];
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 3진법 뒤집기 (0) | 2024.02.09 |
---|---|
[프로그래머스] 내적 (0) | 2024.02.09 |
[프로그래머스] 약수의 개수와 덧셈 (0) | 2024.02.09 |
[프로그래머스] 부족한 금액 계산하기 (0) | 2024.02.09 |
[프로그래머스] 없는 숫자 더하기 (0) | 2024.02.09 |