first and second made of lowercase English letters. Any number of times you may apply two operations to a word:
- **swap** the positions of any two letters, e.g. abcde → aecdb;
- **relabel** two letters present in the word: every occurrence of one becomes the other and vice versa, e.g. aacabb → bbcbaa (a and b traded places).
Return True if one word can be turned into the other with these operations, and False otherwise.first='tree', second='rett' → True
Swap the names of t and e: "tree" turns into "ertt", and rearranging the letters gives "rett".
first='aab', second='bbc' → False
The first word has no c, and neither operation can introduce a new letter.
first='abbccc', second='aabbbc' → True
first='tree', second='rett'
True
Run checks the first 3 tests in your browser. Submit checks all 109 tests on the server, hidden ones included.