New update is available. Click here to update.

Last Updated: 23 Feb, 2021

Difficulty: Moderate

```
Let ‘ARR[]’ = [1, 2, -1] and ‘X’ = 1, ’Y’ =2 and ‘Z’ = 1. Then, for each element at index ‘i’ in the ‘ARR’:
For ‘i’ = 0, ‘ARR[0]’ = 1 and after applying the equation as ‘1 * (1 * 1) + 2 * (1) + 1‘ ‘ARR[0]’ becomes 4.
For ‘i’ = 1, ‘ARR[1]’ = 2 and after applying the equation as ‘1 * (2 * 2) + 2 * (2) + 1‘ ‘ARR[1]’ becomes 9 .
For ‘i’ = 2, ‘ARR[2]’ = -1 and after applying the equation as ‘1 * (-1 * -1) + 2 * (-1) + 1‘ ‘ARR[2]’ becomes 0.
So, ‘ARR’ after modification [4, 9, 0]. The final ‘ARR’ after sorting is [0, 4, 9].
```

```
The first line of input contains an integer ‘T’ which denotes the number of test cases to be run. Then the test cases follow.
The first line of each test case contains four single space-separated integers ‘N’, ’X’, ’Y’, and ‘Z’ representing the number of elements in the array/list ‘ARR’ and three coefficients of a quadratic equation.
The next line of each test case contains ‘N’ single space-separated integers denoting the elements of ‘ARR’.
```

```
For each test case, print the sorted ‘ARR’ after applying the given equation.
Print the output of each test case in a separate line.
```

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

```
1 <= ‘T’ <= 100
1 <= ‘N’ <= 5000
-10^5 <= ‘X’, ‘Y’ and ‘Z’ <= 10^5
-10^5 <= ‘ARR[i]’ <= 10^5
Where 'ARR[i]' denotes the 'ith' element of the array.
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Longest Subarray With Zero Sum

Posted: 3 Nov, 2022

Difficulty: Moderate

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Negative To The End

Posted: 16 Dec, 2022

Difficulty: Easy

Sort 0s, 1s, 2s

Posted: 24 Dec, 2022

Difficulty: Easy

Popular Interview Problems: