LeetCode 二进制链表转整数

119 阅读1分钟

image.png

原题链接

解题思路:2次幂

class Solution {
    public int getDecimalValue(ListNode head) {
        int result =0;
        while(head!=null){
            result = head.val   + (result <<1);
            head = head.next;
        }
        return result ;
    }
}