All Problems

Problem title

Difficulty

Avg time to solve

Nearest Pallindrome

Moderate

30 mins

Flatten 2D array

Easy

20 mins

Maximum Distinct Blocks

Easy

10 mins

Digit Count In Range

Moderate

25 mins

Kevin And The Number On A Dice

Easy

10 mins

Product of the Last K Numbers

Easy

15 mins

Letter Case Permutation

Moderate

15 mins

Distribution of Money

Easy

15 mins

Kevin and the tower of coins

Moderate

25 mins

Ninja and Binary Tree

Moderate

25 mins

Problem

Submissions

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
The first line of the input contains an integer, 'T’ denoting the number of test cases.
The first line of each test case contains two space-separated integers, 'N' and 'K', denoting the number of elements in the array 'ARR', and the special number respectively.
The second line of each test case contains 'N' space-separated integers denoting the elements of the array 'ARR'.
```

```
For each test case, print the minimum number of transactions needed to make the wallet balance of all the friends equal.
Print the output of each test case in a new line.
```

```
You do not need to print anything. It has already been taken care of. Just implement the given function.
```

```
1 <= T <= 10
1 <= N <= 10^5
1 <= K <= 10^4
0 <= ARR[i] <= 10^4
Where 'ARR[i]' represents the ith element of 'ARR'.
Time Limit: 1 sec
```

```
2
4 2
4 6 6 8
3 3
4 2 6
```

```
1
-1
```

```
For the first test case :
If Person 4 gives Rs. 2 to Person 1, then the balance of all four persons will be Rs. 6. Hence, the answer is 1 in this case.
For the second test case :
It is not possible to distribute money equally between friends. Hence, the answer is -1 in this case.
```

```
2
4 1
3 3 7 3
4 2
3 3 3 3
```

```
3
0
```

```
For the first test case :
If Person 3 gives Rs. 1 to rest all Persons, then the balance of all four persons will be Rs. 4. Hence, the answer is 3 in this case.
For the second test case :
The money is already equal and so, we dont need to do any further transactions.
```

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