Count Inversions
BRUTE FORCEunknown
java
10 months ago
348 B
13
Indexable
import java.util.* ;
import java.io.*;
public class Solution {
public static long getInversions(long arr[], int n) {
int i, j, c = 0;
for(i=0;i<n;++i)
{
for(j=i+1;j<n;++j)
{
if(arr[i]>arr[j])
c++;
}
}
return c;
}
}Editor is loading...
Leave a Comment