Description
Two strings are close if you can attain one from the other using operations: swap characters or transform characters by frequency.
Examples
Input:
word1 = "abc", word2 = "bca"Output:
trueExplanation:
Can swap to match.
Input:
word1 = "a", word2 = "aa"Output:
falseExplanation:
For word1 = "a", word2 = "aa", the answer is false because the determine if two strings are close condition is not met.
Input:
word1 = "cabbba", word2 = "abbccc"Output:
trueExplanation:
For word1 = "cabbba", word2 = "abbccc", the answer is true because the determine if two strings are close condition is satisfied.
Constraints
- •
1 ≤ word1.length, word2.length ≤ 10⁵