Closed twy30 closed 3 years ago
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/
public class Solution { public int GetDecimalValue(ListNode head) { // 「頭節點」 var headNode = head; // 「輸出值」 var output = headNode.val; // 「節點」 var node = headNode.next; while (node != null) { output *= 2; output += node.val; node = node.next; } return output; } }
請參考「刷 LeetCode 練習命名」 https://github.com/EngTW/English-for-Programmers/issues/69 😊
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/
請參考「刷 LeetCode 練習命名」 https://github.com/EngTW/English-for-Programmers/issues/69 😊