Array Squares Sorted
Create a class SquaredSorter
that provides a single class method named maxOfSortedSquares
.
maxOfSortedSquares
accepts an array of int
s.
If the passed array is null
or empty, throw an IllegalArgumentException
.
Otherwise, proceed as follows.
First, square every value of the array.
Next, sort the array in ascending order.
Finally, return the maximum of the squared, sorted array.
Modify the array in place, and do not create a copy.
Sort the array using a helper method from java.util.Arrays
.