#1290
Convert Binary Number in a Linked List to Integer
newbie · 145 · lc easy +13 · verified · 82.3% accepted · 4,671 likes · top 94%
Description
A singly-linked list stores a binary number: each node's value is either 0 or 1, with the most significant bit at the head.
Convert this binary representation to its decimal integer value and return it.
Example 1:
Input: head = [1,0,1]
Output: 5
Explanation: (101) in base 2 = (5) in base 10
Example 2:
Input: head = [0]
Output: 0
Code
1
2
3
4
5
6
7
8