All Problems

Problem title

Difficulty

Avg time to solve

Replace 0s

Moderate

30 mins

Print Name

Easy

5 mins

Ninja And The LCM

Easy

15 mins

Minimum Swaps To Make Identical Array

Moderate

--

String Reverse

Easy

10 mins

Total Negative Numbers In A Sorted Matrix

Easy

--

Strings Sum

Easy

--

Postorder Binary Tree

Easy

15 mins

Valid Pallindrome ll

Easy

--

Binary Linked List To Integer

Easy

--

Problem

Submissions

4

Problem Statement

```
n = 4, list: 1 -> 0 -> 1 -> 0.
```

```
Now in this example, the value in the linked list is 1010, which is 10 in Decimal.
Hence the answer is 10.
```

```
The first line contains a single integer ‘T’ denoting the number of test cases. Then each test case follows:
The first line of each test case contains an integer, ‘n’, denoting the number of nodes in the linked list.
The next ‘M’ lines of the test case contain two space-separated integers, ‘x’ and ‘y’, denoting a track between ‘x’ and ‘y’.
The last line of the test case contains ‘n + 1’ space-separated integers which are the nodes of the linked list and each line ends with -1 to indicate that the sublist is over. Thus, -1 will never be a linked list element.
```

```
For each test case, print the Decimal representation of the number.
Output for each test case will be printed in a separate line.
```

```
You are not required to print anything; it has already been taken care of. Just implement the function and return the answer.
```

```
1 <= T <= 100
1 <= N <= 3000
Time Limit: 1sec
```

```
2
3
1 0 1 -1
2
1 1 -1
```

```
5
3
```

```
In the first test case, there are two paths from 1 to 3. I.e. 1 -> 2 -> 3 or 1 -> 0 -> 3 and both these paths have no common track.
Hence the answer is 0.
In the second test case, there are two different paths from 1 to 0. i.e. , 1 -> 2 -> 3 -> 6 -> 0 and 1 -> 2 -> 4 -> 6 -> 0. Having two common tracks, 1 -> 2 and 6 -> 0.
Hence the answer is 2.
```

```
2
1
1 -1
3
1 0 0 -1
```

```
1
4
```

Java (SE 1.8)

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Theme

Solution submission not allowed

Save Code

Reset Code