All Problems

Problem title

Difficulty

Avg time to solve

Ninja and power of 2

Easy

15 mins

Starfield

Easy

15 mins

Play with Pattern

Easy

20 mins

Rectangular Numbers

Moderate

30 mins

Print the Pattern

Moderate

25 mins

Frequency In A Sorted Array

Easy

15 mins

Construct complete Binary Tree

Easy

15 mins

Binary to Decimal

Easy

15 mins

Admission in Ninja Gram

Easy

15 mins

Construct a strict binary tree

Moderate

25 mins

Problem

Submissions

6

Avg. time to solve

15 min

Success Rate

80%

Problem Statement

```
A binary string is a string in which all characters are either ‘1’ or ‘0’.
```

```
The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains a single integer ‘N’ denoting the size of the given string.
The second line of each test case contains the string ‘S’ .
```

```
For each test case, print the corresponding Decimal number (as Integer).
The output of each test case will be printed in a separate line.
```

```
You do not need to input or print anything, as it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 5
1 <= N <= 30
Where ‘T’ is the total number of test cases and ‘N’ is the size of the given string.
The second line of each test case contains the string ‘S’.
Time limit: 1 sec
```

```
2
7
1010101
4
1011
```

```
85
11
```

```
Test case 1:
The Decimal equivalent of the Binary number “1010101” is 85.
Test case 2:
The Decimal equivalent of the Binary number “1011” is 11.
```

```
2
4
1111
1
0
```

```
15
0
```

```
Test case 1:
The Decimal equivalent of the Binary number “1111” is 15.
Test case 2:
The Decimal equivalent of the Binary number “0” is 0.
```

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