315. Count of Smaller Numbers After Self
常规暴力破解解法:

class Solution {
public:
    vector<int> countSmaller(vector<int>& nums) {
        int n = nums.size();
        vector<int> res;
        for(int i = 0;i < n;i++)
        {
            int cnt = 0;
            for(int j = i +1;j < n;j++)
            {
                if(nums[j] < nums[i])
                    cnt++;
            }
            res.push_back(cnt);
        }
        
        return res;
    }
};

我们可以看到执行结果:

16 / 16 test cases passed, but took too long.