Skip to content

Commit 1185eb6

Browse files
committed
Time: 436 ms (7.19%), Space: 20.7 MB (32.93%) - LeetHub
1 parent 9737ef8 commit 1185eb6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
bool closeStrings(string word1, string word2) {
4+
vector<int>w1(26,0),w2(26,0);
5+
set<char>s1,s2;
6+
for(char c:word1){
7+
w1[c-'a']++;
8+
s1.insert(c);
9+
}
10+
for(char c:word2){
11+
w2[c-'a']++;
12+
s2.insert(c);
13+
}
14+
sort(begin(w1),end(w1));
15+
sort(begin(w2),end(w2));
16+
return w1==w2&&s1==s2;
17+
}
18+
};

0 commit comments

Comments
 (0)