1290. 二进制链表转整数

int getDecimalValue(struct ListNode* head){
    int res = 0;
    while (head) {
        res <<= 1;
        res += head->val;
        head = head->next;
    }
    return res;
}

  

原文地址:https://www.cnblogs.com/luckygxf/p/12284314.html