1 parent e31ec85 commit a817461Copy full SHA for a817461
1 file changed
leetcode3/황은지/315. Count of Smaller Numbers After Self.js
@@ -0,0 +1,20 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {number[]}
4
+ */
5
+var countSmaller = function (nums) {
6
+ const output = Array(nums.length);
7
+ // 이렇게 하니까 잘못 참조 함..
8
+ for (let i = nums.length - 1; i >= 0; i--) {
9
+ output[i] = 0;
10
+ for (let j = i + 1; j < nums.length; j++) {
11
+ if (nums[j] <= nums[i]) {
12
+ if (nums[j] === nums[i]) output[i] = output[j];
13
+ else output[i] = output[j] + 1;
14
+ break;
15
+ }
16
17
18
+
19
+ return output;
20
+};
0 commit comments