Skip to content

Commit 35ea902

Browse files
authored
Create groups-of-special-equivalent-strings.cpp
1 parent 4e33197 commit 35ea902

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Time: O(n * l)
2+
// Space: O(n)
3+
4+
class Solution {
5+
public:
6+
int numSpecialEquivGroups(vector<string>& A) {
7+
unordered_set<string> lookup;
8+
for (const auto& s: A) {
9+
string count(52, 0);
10+
for (int i = 0; i < s.length(); ++i) {
11+
++count[s[i] - 'a' + 26 * (i % 2)];
12+
}
13+
lookup.emplace(count);
14+
}
15+
return lookup.size();
16+
}
17+
};

0 commit comments

Comments
 (0)