Skip to content

Commit 053daf7

Browse files
add 2085
1 parent 7211974 commit 053daf7

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+
package com.fishercoder.solutions;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class _2085 {
7+
public static class Solution1 {
8+
public int countWords(String[] words1, String[] words2) {
9+
Map<String, Integer> map1 = new HashMap<>();
10+
Map<String, Integer> map2 = new HashMap<>();
11+
for (String word : words1) {
12+
map1.put(word, map1.getOrDefault(word, 0) + 1);
13+
}
14+
for (String word : words2) {
15+
map2.put(word, map2.getOrDefault(word, 0) + 1);
16+
}
17+
int ans = 0;
18+
for (String key : map1.keySet()) {
19+
if (map1.get(key) == 1 && map2.containsKey(key) && map2.get(key) == 1) {
20+
ans++;
21+
}
22+
}
23+
return ans;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy