Login

All Problems

Problem title

Difficulty

Avg time to solve

LCA of three Nodes

Easy

20 mins

Sum Of Infinite Array

Moderate

35 mins

Pair Sum

Easy

15 mins

Sum or Product

Easy

15 mins

Reverse The Array

Easy

15 mins

Yogesh And Primes

Moderate

20 mins

Find Duplicate in Array

Easy

15 mins

Beautiful String

Easy

18 mins

Longest Univalue Path

Moderate

10 mins

Sort 0 1 2

Easy

22 mins

Problem

Submissions

256

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
We have an array ARR = {1, 2, 3, 4, 5, 6} and M = 3 , considering 0
based indexing so the subarray {5, 6} will be reversed and our
output array will be {1, 2, 3, 4, 6, 5}.
```

```
The very first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of every test case contains one integer ‘N’ where ‘N’ denotes the number of elements and an integer ‘M’ which denotes after which position the array has to be reversed.
The second line of every test case contains ‘N’ space-separated integers which denote the elements of input of array/list.
```

```
For each test case, return the required array.
Output for each test case is printed on a separate line.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
Consider 0-based indexing of the array.
```

```
1 <= T <= 10
0 <= M <= N <= 5*10^4
-10^9 <= ARR[i] <= 10^9
Time Limit: 1 sec
```

```
2
6 3
1 2 3 4 5 6
5 2
10 9 8 7 6
```

```
1 2 3 4 6 5
10 9 8 6 7
```

```
For the first test case,
Considering 0-based indexing we have M = 3 so the
subarray[M+1 … N-1] has to be reversed.
Therefore the required output will be {1, 2, 3, 4, 6, 5}.
For the second test case,
Considering 0-based indexing we have M = 2 so the
subarray[M+1 … N-1] has to be reversed.
Therefore the required output will be {10, 9, 8, 6, 7}.
```

```
2
7 3
1 4 5 6 6 7 7
9 3
10 4 5 2 3 6 1 3 6
```

```
1 4 5 6 7 7 6
10 4 5 2 6 3 1 6 3
```

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 Language

Change Theme

Solution submission not allowed

Save Code

Reset Code