简单链表题
/**
* 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<int> nums;
while(head!=NULL){
nums.push_back(head->val);
head = head->next;
}
int res = 0;
for(int i=0;i<nums.size();i++){
res += nums[i]*pow(2, nums.size()-1-i);
}
return res;
}
};