Skip to content

Commit 3479d54

Browse files
committed
Time: 13 ms (47.95%), Space: 39 MB (73.10%) - LeetHub
1 parent 993e508 commit 3479d54

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
I:int[]
3+
O:int[]
4+
C:
5+
E:
6+
Solution
7+
1. nums를 돌면서 첫번째부터 차례대로 해당 값과 나머지 값들을 비교한다.
8+
Time:O(n^2)
9+
Space:
10+
*/
11+
class Solution {
12+
public int[] smallerNumbersThanCurrent(int[] nums) {
13+
int[] res = new int[nums.length];
14+
for(int i = 0; i < nums.length; i++){
15+
int count = 0;
16+
for(int j = 0; j < nums.length; j++){
17+
if(nums[i]>nums[j]){
18+
count++;
19+
}
20+
res[i] = count;
21+
}
22+
}
23+
return res;
24+
}
25+
}

0 commit comments

Comments
 (0)