bits stores a binary number: each node holds one bit, 0 or 1. The first node is the most significant bit and the last one is the least significant.
Return the value of this number as a regular integer.bits=list_node([1, 1, 0]) → 6
Binary 110 is 4 + 2 = 6.
bits=list_node([1, 0, 0, 1, 1]) → 19
10011₂ = 16 + 2 + 1 = 19.
bits=list_node([0, 1]) → 1
A leading zero changes nothing: 01₂ = 1.
Node.val is 0 or 1bits=list_node([1, 1, 0])
6
Run checks the first 3 tests in your browser. Submit checks all 62 tests on the server, hidden ones included.