Convert Binary Number in a Linked List to Integer (LeetCode)

1290. Convert Binary Number in a Linked List to Integer (Easy)

Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.

Return the decimal value of the number in the linked list.

Brute force approach to solve this problem

Traverse the Linked list and store the elements in the array. You can easily convert the array to decimal.

I hope you like this solution, comment down the most optimal solution of yours. Thanks!

Leave a Comment