当前位置: 代码迷 >> 综合 >> 1290. 二进制链表转整数 Convert Binary Number in a Linked List to Integer
  详细解决方案

1290. 二进制链表转整数 Convert Binary Number in a Linked List to Integer

热度:76   发布时间:2024-01-26 03:50:56.0

题目 https://leetcode-cn.com/problems/convert-binary-number-in-a-linked-list-to-integer/

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     struct ListNode *next;* };*/int getDecimalValue(struct ListNode* head){int num = 0;struct ListNode* node = head;while(node != NULL){num = num<<1;num |= node->val;node = node->next;}return num;
}

 

  相关解决方案