Decimal Equivalent of Binary Linked List
Submissions: 10492   Accuracy:

28.2%

  Difficulty: Easy   Marks: 2

Given a singly linked list of 0s and 1s find its decimal equivalent

   Input  : 0->0->0->1->1->0->0->1->0
   Output : 50
   

Decimal Value of an empty linked list is considered as 0.

Since the answer can be very large, answer modulo 1000000007 should be printed.

Input:
The task is to complete the method which takes one argument: the head of the linked list. The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list. 
There are multiple test cases. For each test case, this method will be called individually.

Output:
The function should return should decimal equivalent modulo 1000000007

Constraints:
1 <=T<= 200
0 <=N<= 100
Data of Node is either 0 or 1

Example:
Input:

2
3
0 1 1    
4
1 1 1 0

Output:
3
14

 

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.
 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal, Harshit Sidhwa
Author: kartik


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.