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

Commit49bb98f

Browse files
add 2053
1 parent07d09a0 commit49bb98f

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+
|2053|[Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2053.java)||Easy||
1112
|2050|[Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2050.java)||Hard||
1213
|2048|[Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2048.java)||Medium||
1314
|2047|[Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2047.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.HashMap;
4+
importjava.util.Map;
5+
6+
publicclass_2053 {
7+
publicstaticclassSolution1 {
8+
publicStringkthDistinct(String[]arr,intk) {
9+
Map<String,Integer>map =newHashMap<>();
10+
for (Strings :arr) {
11+
map.put(s,map.getOrDefault(s,0) +1);
12+
}
13+
intcount =0;
14+
for (Strings :arr) {
15+
if (map.get(s) ==1) {
16+
count++;
17+
if (k ==count) {
18+
returns;
19+
}
20+
}
21+
}
22+
return"";
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp