All Problems

Problem title

Difficulty

Avg time to solve

Sliding Maximum

Moderate

25 mins

Print Leaf Nodes

Easy

33 mins

Subarrays With Zero Sum

Easy

--

Preorder Binary Tree

Easy

10 mins

Sort Array of 0s and 1s.

Easy

10 mins

Preorder Traversal

Easy

15 mins

TIme-Based Key Value Store

Moderate

15 mins

Travelling Salesman Problem

Hard

50 mins

Perfect Rectangle

Moderate

20 mins

Unbounded Knapsack

Moderate

15 mins

Problem

Submissions

13

Avg. time to solve

10 min

Success Rate

90%

Problem Statement

```
For the following array:
[0 1 1 1 0 0 1]
The output should be [0 0 0 1 1 1 1].
```

```
You have to sort the array in place.
```

```
The first line will contain a single integer ‘T’ denoting the number of test cases. Then the test cases follow.
The first line of each test case will contain a single integer ‘N’, denoting the size of the array.
The second line of each test case will contain ‘N’ space-separated integers, denoting the elements of the array.
```

```
For each test case, print the input array after sorting it.
```

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

```
1 <= T <= 5
1 <= N <= 10^5
A[i] = 0 or 1
Time Limit: 1 sec.
```

```
2
4
1 0 1 0
6
0 1 1 0 0 0
```

```
0 0 1 1
0 0 0 0 1 1
```

```
For the first test case, the sorted array will be [0 0 1 1].
For the second test case, the sorted array will be [0 0 0 0 1 1].
```

```
2
10
0 1 1 0 1 0 1 1 0 0
8
1 1 1 0 0 1 0 1
```

```
0 0 0 0 0 1 1 1 1 1
0 0 0 1 1 1 1 1
```

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