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.

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.

KshatriyaYash | 658 |

RuntimeTerror | 446 |

nikhil_sojan | 388 |

cypherr | 384 |

striver119 | 378 |

KshatriyaYash | 1066 |

nikhil_sojan | 972 |

lonecoder | 909 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4462 |

Quandray | 4444 |

Login to report an issue on this page.