9

PROBLEM OF THE DAY : 03/01/2024 | Decimal Equivalent of Binary Linked List

 7 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-03012024-decimal-equivalent-of-binary-linked-list/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Decimal Equivalent of Binary Linked List

February 05, 2024 |370 Views
PROBLEM OF THE DAY : 03/01/2024 | Decimal Equivalent of Binary Linked List
Problem of the Day, linked-list, Data Structure and Algorithm
 Save  Share   Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Linked List but also build up problem-solving skills.

In this problem, we are given a singly linked list of length n. The link list represents a binary number, ie- it contains only 0s and 1s. Find its decimal equivalent.
The significance of the bits decreases with the increasing index in the linked list.
An empty linked list is considered to represent the decimal value 0.

Since the answer can be very large, answer modulo 109+7 should be printed.

Example :

Input:
n = 3
Linked List = {0, 1, 1}
Output:
3
Explanation:
0*22 + 1*21 + 1*20 =  1 + 2 + 0 = 3

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/decimal-equivalent-of-binary-linked-list/1

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK