/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    int getDecimalValue(ListNode* head) {
        std::vector<int> v;
        while (head) {
            v.emplace_back(head->val);
            head = head->next;
        }
        int ret = 0, index = 1;
        for (int i = 0; i < v.size(); ++i) {
            ret += v[v.size()-i-1] * index;
            index *= 2;
        }
        return ret;
    }
};

Convert Binary Number in a Linked List to Integer
Convert Binary Number in a Linked List to Integer
