File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,776 LeetCode solutions in JavaScript
1
+ # 1,777 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1645
1645
2144|[ Minimum Cost of Buying Candies With Discount] ( ./solutions/2144-minimum-cost-of-buying-candies-with-discount.js ) |Easy|
1646
1646
2145|[ Count the Hidden Sequences] ( ./solutions/2145-count-the-hidden-sequences.js ) |Medium|
1647
1647
2147|[ Number of Ways to Divide a Long Corridor] ( ./solutions/2147-number-of-ways-to-divide-a-long-corridor.js ) |Hard|
1648
+ 2148|[ Count Elements With Strictly Smaller and Greater Elements] ( ./solutions/2148-count-elements-with-strictly-smaller-and-greater-elements.js ) |Easy|
1648
1649
2154|[ Keep Multiplying Found Values by Two] ( ./solutions/2154-keep-multiplying-found-values-by-two.js ) |Easy|
1649
1650
2161|[ Partition Array According to Given Pivot] ( ./solutions/2161-partition-array-according-to-given-pivot.js ) |Medium|
1650
1651
2176|[ Count Equal and Divisible Pairs in an Array] ( ./solutions/2176-count-equal-and-divisible-pairs-in-an-array.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2148. Count Elements With Strictly Smaller and Greater Elements
3
+ * https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an integer array nums, return the number of elements that have both a strictly
7
+ * smaller and a strictly greater element appear in nums.
8
+ */
9
+
10
+ /**
11
+ * @param {number[] } nums
12
+ * @return {number }
13
+ */
14
+ var countElements = function ( nums ) {
15
+ let result = 0 ;
16
+
17
+ if ( nums . length <= 2 ) return 0 ;
18
+ for ( const num of nums ) {
19
+ if ( num > Math . min ( ...nums ) && num < Math . max ( ...nums ) ) {
20
+ result ++ ;
21
+ }
22
+ }
23
+
24
+ return result ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments