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

Commit8c3647b

Browse files
add 1629
1 parent4651eaa commit8c3647b

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _If you like this project, please leave me a star._ ★
99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
1111
|1630|[Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1630.java)||Medium|Sort|
12+
|1629|[Slowest Key](https://leetcode.com/problems/slowest-key/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1629.java)||Easy|Array|
1213
|1626|[Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1626.java)||Medium|DP|
1314
|1625|[Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1625.java)||Medium|BFS, DFS|
1415
|1624|[Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1624.java)||Easy|String|
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.Collections;
5+
importjava.util.HashMap;
6+
importjava.util.List;
7+
importjava.util.Map;
8+
9+
publicclass_1629 {
10+
publicstaticclassSolution1 {
11+
publiccharslowestKey(int[]releaseTimes,StringkeysPressed) {
12+
Map<Character,Integer>map =newHashMap<>();
13+
for (inti =0;i <releaseTimes.length;i++) {
14+
charc =keysPressed.charAt(i);
15+
intduration;
16+
if (i ==0) {
17+
duration =releaseTimes[i];
18+
}else {
19+
duration =releaseTimes[i] -releaseTimes[i -1];
20+
}
21+
if (!map.containsKey(c)) {
22+
map.put(c,duration);
23+
}else {
24+
intval =map.get(c);
25+
if (duration >val) {
26+
map.put(c,duration);
27+
}
28+
}
29+
}
30+
Map<Integer,List<Character>>map2 =newHashMap<>();
31+
for (charc :map.keySet()) {
32+
intduration =map.get(c);
33+
if (!map2.containsKey(duration)) {
34+
map2.put(duration,newArrayList<>());
35+
}
36+
map2.get(duration).add(c);
37+
}
38+
intmax = -1;
39+
for (intduration :map2.keySet()) {
40+
List<Character>chars =map2.get(duration);
41+
Collections.sort(chars);
42+
map2.put(duration,chars);
43+
max =Math.max(max,duration);
44+
}
45+
returnmap2.get(max).get(map2.get(max).size() -1);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp