1290.cpp (198B)
1 class Solution { 2 public: 3 int getDecimalValue(ListNode *head) { 4 int res = 0; 5 for (; head; head = head->next) 6 res = res * 2 + head->val; 7 return res; 8 } 9 };