Description
Two strings are close if you can attain one from the other using operations: swap characters or transform characters by frequency. Return true or false.
Examples
Input:
word1 = "abc", word2 = "bca"Output:
trueExplanation:
Both have same characters {a,b,c} with same frequencies [1,1,1]. Swap operations transform 'abc' to 'bca'.
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⁵