Class Solution
java.lang.Object
g1201_1300.s1290_convert_binary_number_in_a_linked_list_to_integer.Solution
1290 - Convert Binary Number in a Linked List to Integer.<p>Easy</p>
<p>Given <code>head</code> which is a reference node to a singly-linked list. The value of each node in the linked list is either <code>0</code> or <code>1</code>. The linked list holds the binary representation of a number.</p>
<p>Return the <em>decimal value</em> of the number in the linked list.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2019/12/05/graph-1.png" alt="" /></p>
<p><strong>Input:</strong> head = [1,0,1]</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> (101) in base 2 = (5) in base 10</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> head = [0]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The Linked List is not empty.</li>
<li>Number of nodes will not exceed <code>30</code>.</li>
<li>Each node’s value is either <code>0</code> or <code>1</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
getDecimalValue
-