[JS] 프로그래머스 0단계: 정답률 78%

ahyes·2022년 12월 11일
0
post-thumbnail

안녕하세요.
이어서 정답률 78% 문제를 풀어보겠습니다.

  1. 이진수 더하기
function solution(bin1, bin2) {
    return (parseInt(bin1,2)+parseInt(bin2,2)).toString(2);
}
  1. 한 번만 등장한 문자
function solution(s) {
    s = [...s].sort();
    let answer = '';
    for(let i = 0; i<s.length;i++){
        if(s.lastIndexOf(s[i]) === i && s.indexOf(s[i]) === i){
            answer +=  s[i];
        }
    }
    return answer;
}
profile
티스토리로 이사갑니다. https://useyhnha.tistory.com/

0개의 댓글