Skip to content

Commit ed1d552

Browse files
add 2148
1 parent aa9b319 commit ed1d552

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2148|[Count Elements With Strictly Smaller and Greater Elements](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2148.java) ||Easy||
1112
|2144|[Minimum Cost of Buying Candies With Discount](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2144.java) ||Easy||
1213
|2139|[Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2139.java) ||Medium||
1314
|2138|[Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2138.java) ||Easy||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.TreeMap;
4+
5+
public class _2148 {
6+
public static class Solution1 {
7+
public int countElements(int[] nums) {
8+
TreeMap<Integer, Integer> treeMap = new TreeMap<>();
9+
for (int num : nums) {
10+
treeMap.put(num, treeMap.getOrDefault(num, 0) + 1);
11+
}
12+
int ans = 0;
13+
int i = 0;
14+
int len = treeMap.size();
15+
for (int key : treeMap.keySet()) {
16+
if (i != 0 && i != len - 1) {
17+
ans += treeMap.get(key);
18+
}
19+
i++;
20+
}
21+
return ans;
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)