Check if One String Swap Can Make Strings Equal
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given two strings s1 and s2 of equal length. A *string swap* picks two indices in one string (they may be the same index) and exchanges the characters at those positions.
Return true if you can make the strings equal by performing **at most one** swap on **exactly one** of the strings. Strings that are already equal return true.
Examples
Constraints
- 1 <= s1.length, s2.length <= 100
- s1.length == s2.length
- `s1` and `s2` consist of lowercase English letters.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.