Count Inversions
BRUTE FORCEAnonymous
java
02/04/2025 7:23 AM
464 B
47
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