Login

All Problems

Problem title

Difficulty

Avg time to solve

Count Subsequences

Moderate

30 mins

Maximum length pair chain

Moderate

15 mins

Sort a Stack

Easy

10 mins

Relative Sorting

Moderate

25 mins

Next Greater Element

Moderate

20 mins

Roots of the tree having minimum height

Moderate

25 mins

Longest Palindromic Substring

Easy

20 mins

Remove K Corner Elements

Easy

15 mins

Number Pattern 1

Easy

10 mins

Ninja and characters

Easy

15 mins

Problem

Submissions

15

Avg. time to solve

15 min

Success Rate

80%

Problem Statement

```
If N = 7 and K = 3, and the input array is:
{1, 2, 3, 4, 5, 6, 7}
After removing the first three elements, the resulting array now becomes {4, 5, 6, 7} and the sum of the remaining array is equal to 22.
Removing any other combination of three elements will always result in the remaining array sum less than 22.
```

```
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 two integers ‘N’ and ‘K’, where N denotes the length of the given array and K denotes the number of elements to be removed.
The next line of each test case contains N integers denoting array elements ‘arr[i]’.
```

```
For each test case print a single integer denoting the maximum sum of the remaining array.
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.
```

```
1 <= T <= 10
1 <= N <= 10^4
0 <= K <= N
0 <= arr[i] <=10^6
Time limit: 1 sec
```

```
2
6 3
1 2 6 4 5 3
8 4
5 3 1 1 8 8 2 2
```

```
15
20
```

```
For test case 1 :
After removing two elements from the beginning and one element from the end, the original array now becomes {6, 4, 5}. The remaining elements of the array have a sum equal to 15.
For test case 2 :
After removing four elements from the beginning, the original array now becomes {8, 8, 2, 2}. The remaining elements of the array have a sum equal to 20.
```

```
2
5 5
4 5 7 2 3
5 0
1 2 3 4 5
```

```
0
15
```

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