class Solution {
public String solution(String bin1, String bin2) {
String answer = "";
int sum = 0;
int binarBin1 = Integer.parseInt(bin1,2);
int binarBin2 = Integer.parseInt(bin2,2);
sum = binarBin1+binarBin2;
answer = String.valueOf(Integer.toBinaryString(sum));
return answer;
}
}
2진수 표현은 문자열로 가능하다.
2진수>10진수로 만들어서 덧셈연산.
덧셈 결과 sum은 String으로 변환해주고 리턴.
'프로그래머스' 카테고리의 다른 글
[프로그래머스] 없는 숫자 더하기 (0) | 2022.12.01 |
---|---|
[프로그래머스] 문자열 다루기 기본 (0) | 2022.12.01 |
[프로그래머스] 부족한 금액 계산하기 (0) | 2022.11.30 |
[프로그래머스] 개미 군단 (0) | 2022.11.29 |
[프로그래머스] 나누어 떨어지는 숫자 배열 (0) | 2022.11.29 |