Back to course home
0% completed
Vote For New Content
Solution: Determine if Two Strings Are Close
Problem Statement:
Two strings are considered similar if you can make one string look like the other using the following two operations:
- Swap any two characters.
- For example, abde -> aedb (
eandbswapped).
- For example, abde -> aedb (
- Replace every occurrence of one character with another, and replace the other character with the first one.
- For example, acabbb -> bcbaaa (all a's turn into b's, and all b's turn into a's)
Given two strings, word1 and word2, return true if they can be made similar, otherwise return false.
Examples
Example 1:
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page