simple java solution
\tclass Solution {\n\t\tpublic static int numTeams(int[] rating) {\n\t\t\tint n = rating.length;\n\t\t\tint [][] dp = new int[n][2]; // 0 smaller than, 1 greate
\tclass Solution {\n\t\tpublic static int numTeams(int[] rating) {\n\t\t\tint n = rating.length;\n\t\t\tint [][] dp = new int[n][2]; // 0 smaller than, 1 greater than\n\t\t\tint ans = 0;\n\t\t\tfor (int i = 1; i < n; i++) {\n\t\t\t\tfor (int j = 0; j < i; j++) {\n\t\t\t\t\tif(rating[i] < rating[j]){dp[i][0] += 1;ans+=dp[j][0];}\n\t\t\t\t\tif(rating[i] > rating[j]){dp[i][1] += 1;ans+=dp[j][1];}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n}
['Dynamic Programming', 'Java']