최대 1 분 소요


image

What I’ve Learned

LL: Binary to Decimal Review

Solution

I solved by not seeing the hints or solutions. Multiplying 2 to calculate the binary value is a great idea. I need to keep this in mind.

    public int binaryToDecimal(){
        int num = 0;
        Node temp = head;
        while(temp != null){
            num = num * 2 + temp.value;
            temp = temp.next;
        }
        return num;
    }

카테고리:

업데이트: