Skip to content

Commit 576f42b

Browse files
authored
Merge pull request #2 from Piyush6869/Piyush6869-patch-2
Update Count of Smaller Numbers After Self
2 parents 856a723 + b55b841 commit 576f42b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Diff for: LeetcodeProblems/Algorithms/Count of Smaller Numbers After Self

+13-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ Output: [0,0]
1818

1919

2020

21-
def countSmaller(nums):
22-
result = []
23-
for i in range(len(nums)):
24-
count = 0
25-
for j in range(i + 1, len(nums)):
26-
if nums[j] < nums[i]:
27-
count += 1
28-
result.append(count)
29-
return result
21+
function countSmaller(nums) {
22+
const result = [];
23+
for (let i = 0; i < nums.length; i++) {
24+
let count = 0;
25+
for (let j = i + 1; j < nums.length; j++) {
26+
if (nums[j] < nums[i]) {
27+
count += 1;
28+
}
29+
}
30+
result.push(count);
31+
}
32+
return result;
33+
}

0 commit comments

Comments
 (0)