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

Commit4c413a5

Browse files
add 2284
1 parentfaca7d0 commit4c413a5

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------|-------------
11-
| 2283|[Check if Number Has Equal Digit Count and Digit Value](https://leetcode.com/problems/check-if-number-has-equal-digit-count-and-digit-value/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2283.java)|| Easy||
11+
| 2284|[Sender With Largest Word Count](https://leetcode.com/problems/sender-with-largest-word-count/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2284.java)|| Medium||
12+
| 2283|[Check if Number Has Equal Digit Count and Digit Value](https://leetcode.com/problems/check-if-number-has-equal-digit-count-and-digit-value/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2283.java)|| Easy||
1213
| 2279|[Maximum Bags With Full Capacity of Rocks](https://leetcode.com/problems/maximum-bags-with-full-capacity-of-rocks/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2279.java)|| Medium||
1314
| 2278|[Percentage of Letter in String](https://leetcode.com/problems/percentage-of-letter-in-string/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2278.java)|| Easy||
1415
| 2270|[Number of Ways to Split Array](https://leetcode.com/problems/number-of-ways-to-split-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2270.java)|| Medium||
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.HashMap;
4+
importjava.util.Map;
5+
6+
publicclass_2284 {
7+
publicstaticclassSolution1 {
8+
publicStringlargestWordCount(String[]messages,String[]senders) {
9+
Map<String,Integer>map =newHashMap<>();
10+
for (inti =0;i <messages.length;i++) {
11+
Stringsender =senders[i];
12+
intcount =messages[i].split(" ").length;
13+
Integerexisting =map.getOrDefault(sender,0);
14+
map.put(sender,existing +count);
15+
}
16+
intmax =0;
17+
Stringresult ="";
18+
for (Stringsender :map.keySet()) {
19+
if (map.get(sender) >max) {
20+
max =map.get(sender);
21+
result =sender;
22+
}elseif (map.get(sender) ==max) {
23+
if (result.compareTo(sender) <0) {
24+
result =sender;
25+
}
26+
}
27+
}
28+
returnresult;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp