음양 더하기

URL : https://school.programmers.co.kr/learn/courses/30/lessons/76501
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Solution { | |
public int solution(int[] absolutes, bool[] signs) { | |
int answer = 0; | |
for(int i =0;i< absolutes.Length;i++) | |
answer += signs[i] ? absolutes[i] : absolutes[i]*-1; | |
return answer; | |
} | |
} |
<문제해석>
absolutes값을 signs의 부호로 매칭해서 결과값을 처리하는 단순한 문제
★☆☆☆☆
반응형
'개발 > 문제풀이' 카테고리의 다른 글
문제풀이)프로그래머스)단어 변환 (0) | 2022.07.29 |
---|---|
문제풀이)프로그래머스)주차 요금 (0) | 2022.07.26 |
문제풀이)프로그래머스) 로또의 최고 순위와 최저 순위 (0) | 2022.07.19 |
문제풀이)프로그래머스)2022 KAKAO BLIND RECRUITMENT -신고 결과 받기 (0) | 2022.07.19 |
문제풀이)프로그래머스)c#) 삼각 달팽이 (1) | 2021.02.13 |
댓글