728x90
SMALL

using System;

public class Solution {
    public string solution(string bin1, string bin2) {
        string answer = "";
        int ijin = 0;
        
        ijin = Convert.ToInt32(bin1, 2) + Convert.ToInt32(bin2, 2);
        answer = Convert.ToString(ijin, 2);
        
        return answer;
    }
}

 

///////////////

 

파이썬

/////

def solution(bin1, bin2):
    ans = int(bin1,2) +int(bin2,2)
    answer = bin(ans)[2:]
    return answer

////////////

def solution(bin1, bin2):
    return bin(int('0b' + bin1, 2) + int('0b' + bin2, 2))[2:]

 

자바

//////////

 

class Solution {
    public String solution(String bin1, String bin2) {
        return Integer.toBinaryString(Integer.parseInt(bin1, 2) + Integer.parseInt(bin2, 2));
    }
}

 

 

class Solution {
    public String solution(String bin1, String bin2) {
        String answer = "";

        int a = Integer.parseInt(bin1,2);
        int b = Integer.parseInt(bin2,2);
        answer = Integer.toBinaryString(a+b);
        return answer;
    }
}
728x90

설정

트랙백

댓글