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

Commit053daf7

Browse files
add 2085
1 parent7211974 commit053daf7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-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-
|2080|[Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2080.java)||Medium|Array, Binary Seaarch|
11+
|2085|[Count Common Words With One Occurrence](https://leetcode.com/problems/count-common-words-with-one-occurrence/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2085.java)||Easy||
12+
|2080|[Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2080.java)||Medium|Array, Binary Search|
1213
|2079|[Watering Plants](https://leetcode.com/problems/watering-plants/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2079.java)||Medium||
1314
|2078|[Two Furthest Houses With Different Colors](https://leetcode.com/problems/two-furthest-houses-with-different-colors/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2078.java)||Easy||
1415
|2076|[Process Restricted Friend Requests](https://leetcode.com/problems/process-restricted-friend-requests/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2076.java)||Hard||
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.HashMap;
4+
importjava.util.Map;
5+
6+
publicclass_2085 {
7+
publicstaticclassSolution1 {
8+
publicintcountWords(String[]words1,String[]words2) {
9+
Map<String,Integer>map1 =newHashMap<>();
10+
Map<String,Integer>map2 =newHashMap<>();
11+
for (Stringword :words1) {
12+
map1.put(word,map1.getOrDefault(word,0) +1);
13+
}
14+
for (Stringword :words2) {
15+
map2.put(word,map2.getOrDefault(word,0) +1);
16+
}
17+
intans =0;
18+
for (Stringkey :map1.keySet()) {
19+
if (map1.get(key) ==1 &&map2.containsKey(key) &&map2.get(key) ==1) {
20+
ans++;
21+
}
22+
}
23+
returnans;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp