Back to course home
0% completed
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 (
e
andb
swapped).
- 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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible