Skip to content

Commit d167d0f

Browse files
committed
Time: 78 ms (92.13%), Space: 18.2 MB (46.88%) - LeetHub
1 parent 3fd8333 commit d167d0f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from collections import Counter
2+
3+
class Solution:
4+
def closeStrings(self, word1: str, word2: str) -> bool:
5+
if len(word1) != len(word2):
6+
return False
7+
8+
if set(word1) != set(word2):
9+
return False
10+
11+
counter1 = Counter(word1)
12+
counter2 = Counter(word2)
13+
14+
return sorted(counter1.values()) == sorted(counter2.values())

0 commit comments

Comments
 (0)