Back to course home
0% completed
Solution: Similar String Groups
Problem Statement
Two strings, X
and Y
, are considered similar if they are identical or can be made identical by swapping at most two distinct positions.
For example, "abcd"
and "bacd"
are similar (swapping at positions 0 and 1), "abcd"
and "acbd"
are also similar, but "dabc"
is not similar to "abcd"
, "bacd"
, and "acbd"
.
Together, these form two connected groups by similarity: {"abcd"
, "bacd"
, "acbd"
} and {"dabc"
}. Notice that "bacd"
and "acbd"
are in the same group even though they are not similar
.....
.....
.....
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