Determine if Two Strings Are Close LeetCode solution in Python

1
# Runtime: 137 ms (Top 70.4%) | Memory: 17.77 MB (Top 49.0%)
2

3
from collections import Counter
4

5

6
class Solution:
7
def closeStrings(self, word1: str, word2: str) -> bool:
8
return set(word1) == set(word2) and Counter(Counter(word1).values()) == Counter(
9
Counter(word2).values()
10
)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0