File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 142
142
1351|[ Count Negative Numbers in a Sorted Matrix] ( ./1351-count-negative-numbers-in-a-sorted-matrix.js ) |Easy|
143
143
1356|[ Sort Integers by The Number of 1 Bits] ( ./1356-sort-integers-by-the-number-of-1-bits.js ) |Easy|
144
144
1360|[ Number of Days Between Two Dates] ( ./1360-number-of-days-between-two-dates.js ) |Easy|
145
+ 1365|[ How Many Numbers Are Smaller Than the Current Number] ( ./1365-how-many-numbers-are-smaller-than-the-current-number.js ) |Easy|
145
146
1380|[ Lucky Numbers in a Matrix] ( ./1380-lucky-numbers-in-a-matrix.js ) |Easy|
146
147
1472|[ Design Browser History] ( ./1472-design-browser-history.js ) |Medium|
147
148
1598|[ Crawler Log Folder] ( ./1598-crawler-log-folder.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1365. How Many Numbers Are Smaller Than the Current Number
3
+ * https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given the array nums, for each nums[i] find out how many numbers in the array are smaller
7
+ * than it. That is, for each nums[i] you have to count the number of valid j's such that
8
+ * j != i and nums[j] < nums[i].
9
+ *
10
+ * Return the answer in an array.
11
+ */
12
+
13
+ /**
14
+ * @param {number[] } nums
15
+ * @return {number[] }
16
+ */
17
+ var smallerNumbersThanCurrent = function ( nums ) {
18
+ const sorted = nums . slice ( ) . sort ( ( a , b ) => a - b ) ;
19
+ return nums . map ( num => sorted . indexOf ( num ) ) ;
20
+ } ;
You can’t perform that action at this time.
0 commit comments