1290. Convert Binary Number in a Linked List to Integer

简单链表题

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    int getDecimalValue(ListNode* head) {
        vector nums;
        while(head!=NULL){
            nums.push_back(head->val);
            head = head->next;
        }
        
        int res = 0;
        for(int i=0;i

你可能感兴趣的:(leetcode,leetcode)