Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited1d552

Browse files
add 2148
1 parentaa9b319 commited1d552

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
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||
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.TreeMap;
4+
5+
publicclass_2148 {
6+
publicstaticclassSolution1 {
7+
publicintcountElements(int[]nums) {
8+
TreeMap<Integer,Integer>treeMap =newTreeMap<>();
9+
for (intnum :nums) {
10+
treeMap.put(num,treeMap.getOrDefault(num,0) +1);
11+
}
12+
intans =0;
13+
inti =0;
14+
intlen =treeMap.size();
15+
for (intkey :treeMap.keySet()) {
16+
if (i !=0 &&i !=len -1) {
17+
ans +=treeMap.get(key);
18+
}
19+
i++;
20+
}
21+
returnans;
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp