Advertisement
Sort the given array after applying the given equation
JavaView on GFG
Sort the given array after applying the given equation.java
Java
import java.util.*;
class Solution {
public ArrayList<Integer> sortArray(int[] arr, int A, int B, int C) {
ArrayList<Integer> al = new ArrayList<>();
for (int i : arr)
al.add(A * (int) Math.pow(i, 2) + B * i + C);
Collections.sort(al);
return al;
}
}Advertisement
Was this solution helpful?