Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 59d562e

Browse files
committed
Add solution #2148
1 parent f435a3c commit 59d562e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,776 LeetCode solutions in JavaScript
1+
# 1,777 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1645,6 +1645,7 @@
16451645
2144|[Minimum Cost of Buying Candies With Discount](./solutions/2144-minimum-cost-of-buying-candies-with-discount.js)|Easy|
16461646
2145|[Count the Hidden Sequences](./solutions/2145-count-the-hidden-sequences.js)|Medium|
16471647
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|
16481649
2154|[Keep Multiplying Found Values by Two](./solutions/2154-keep-multiplying-found-values-by-two.js)|Easy|
16491650
2161|[Partition Array According to Given Pivot](./solutions/2161-partition-array-according-to-given-pivot.js)|Medium|
16501651
2176|[Count Equal and Divisible Pairs in an Array](./solutions/2176-count-equal-and-divisible-pairs-in-an-array.js)|Easy|
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
};

0 commit comments

Comments
 (0)