Skip to content

Commit 1520b4a

Browse files
committed
Runtime: 25 ms (Top 76.04%) | Memory: 13.10 MB (Top 91.69%)
1 parent 1ef9dce commit 1520b4a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Runtime: 25 ms (Top 76.04%) | Memory: 13.10 MB (Top 91.69%)
2+
3+
class Solution {
4+
public:
5+
int similarPairs(vector<string>& words) {
6+
int ans = 0;
7+
unordered_map<int, int> freq;
8+
for (auto& word : words) {
9+
int mask = 0;
10+
for (auto& c : word) mask |= 1 << (c-'a');
11+
ans += freq[mask]++;
12+
}
13+
return ans;
14+
}
15+
};

0 commit comments

Comments
 (0)