题目描述
blablabla
样例
暴力枚举
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:0(n^2)
C++ 代码
class Solution {
public:
int inversePairs(vector<int>& nums) {
int n = nums.size();
int count = 0;
for (int i = 0; i < n-1; i++)
for (int j = i+1; j < n; j++){
if (nums[i] > nums[j]) count ++;
}
return count;
}
};