03. Decimal Equivalent of Binary Linked List
Last updated
Was this helpful?
Last updated
Was this helpful?
The problem can be found at the following link:
I am iterating through the linked list, treating it as a binary representation of a number.
At each step, I shift the current result left by one bit (multiply by 2) and add the current node's data.
I also take care to update the result modulo 1e9 + 7 to avoid overflow.
Time Complexity : O(N)
, where N is the number of nodes in the linked list.
Auxiliary Space Complexity : O(1)
For discussions, questions, or doubts related to this solution, please visit our . We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star
to the repository.