Given 2 strings s and t, determine if you can convert s into t. The rules are:
You can change 1 letter at a time.
Once you changed a letter you have to change all occurrences of that letter. Example 1:
Input: s = "abca", t = "dced"
Explanation: abca ('a' to 'd') -> dbcd ('c' to 'e') -> dbed ('b' to 'c') -> dced
Input: s = "ab", t = "ba"
Explanation: ab -> ac -> bc -> ba
Input: s = "abcdefghijklmnopqrstuvwxyz", t = "bcdefghijklmnopqrstuvwxyza"
Input: s = "aa", t = "cd"
Input: s = "ab", t = "aa"
Input: s = "abcdefghijklmnopqrstuvwxyz", t = "bbcdefghijklmnopqrstuvwxyz"
Both strings contain only lowercase English letters.
Get one-to-one training from Google Facebook engineers
Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.
Customized Private Class
Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.