A subsequence is created by deleting zero or more elements from a list while maintaining the order. For example, the subsequences of $[1,2,3]$ are $[1],[2],[3],[1,2][1,3],[2,3],[1,2,3]$. An inversion is a strictly decreasing subsequence of length 3 . More formally, given an array, $p=p[n]$ an inversion in the array is any time some $p[i]>p[j]>$ $p[k]$ and $i<j<k$ Determine the number of inversions within a given array. Example \[ \begin{array}{l} n=5 \\ a r r=[5,3,4,2,1] . \end{array} \] The array inversions are: \[ \begin{array}{l} {[5,3,2]} \\ {[5,3,1]} \\ {[5,4,2]} \\ {[5,4,1]} \\ {[5,2,1]} \\ {[3,2,1]} \\ {[4,2,1]} \end{array} \] Example 2 \[ \begin{array}{l} n=4 \\ \text { prices }=[4,2,2,1] \text {. } \\ \end{array} \] The only inversion is $[4,2,1]$ and there are two instances: indices 0 , 1,3 and indices $0,2,3$. The arrays $[4,2,2]$ and $[2,2,1]$ are not considered inversions because they are not strictly decreasing. Function Description Complete the function maxinversions in the editor below. maxinversions has the following parameter(s): int prices $[n]$ : an array of integers Returns long: a long integer denoting the number of Inversions in the array.

class Result \{ I* * Complete the 'maxInversions' function below. * The function is expected to return a LONG_INTEGER. * The function accepts INTEGER_ARRAY arr as parameter. $\star 1$ public static long maxinversions(List<Integer Iarr $^{\text {ard }}$ \{ // Write your code here \} \} $1>$ public class Solution $\{\ldots$
i want this program in java and use same method name and thier parameters as shown in second picture.

Public Answer

CWCV12 The First Answerer