Variant of https://leetcode.com/problems/isomorphic-strings
Given two strings, you have to return true if they are rhyming else false. Strings are rhyming if say,
lying A
dying A
shower B
flower BExample 1:
Input: s1 = "AABB", s2 = "XXYY"
Output: trueExample 2:
Input: s1 = "AABB", s2 = "XYZZ"
Output: falseI did it in O(n) time and O(n) space by using map with key and value as character. Basically I checked if every character from string 1 is having same value in string 2 and vice versa (both dimension) so I called the function checkRhyming(string1, string2) twice in main function. I did it pretty fast (maybe under 10-12 min) so we later jumped into optimization.
By optimization he meant to optimize the code. The follow up was basically, how to optimize for bigger constraint, to which I agreed upon using two map instead of one and doing this by calling function only one time. The space use would increase of course, but that is the tradeoff we could do.
TBH I was expecting one more question because I did it pretty fast, and we have many more minutes left.