315. Count of Smaller Numbers After Self

JJ·2021년 2월 7일
0

Algorithms

목록 보기
98/114
class Solution {
    public List<Integer> countSmaller(int[] nums) {
        List<Integer> result = new ArrayList<Integer>();
        for (int i = 0; i < nums.length; i++) {
            int cur = nums[i];
            int count = 0;
            for (int j = i; j < nums.length; j++) {
                if (nums[j] < cur) {
                    count++;
                }
            }
            result.add(count);
        }
        
        return result;
    }
}

오늘 4문제 다 타임리밋 걸린거 같은데^^...

https://leetcode.com/problems/count-of-smaller-numbers-after-self/discuss/445769/merge-sort-CLEAR-simple-EXPLANATION-with-EXAMPLES-O(n-lg-n)

이거만 믿읍니다

0개의 댓글