My issue
Time Limit Exceeded
My code
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t=0; t<T; t++){
int N = sc.nextInt();
int[] A = new int[N];
for(int i=0; i<N; i++)
A[i] = sc.nextInt();
long ans = 0;
for(int i=0; i<N; i++){
for(int j=i+1; j<N; j++){
if(A[i] > A[j])
ans++;
}
}
System.out.println(ans%1000000007);
}
}
}
Learning course: Design and Analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/kl-daa/KLDAA2402/problems/DAA014