Google | Minimum steps to make a target string
Anonymous User
4874

**Question **

Given two string, say A = "abca", B = "abbac". We can make another string S by concatening A multiple times. Then we can remove any number of charaters from string S.
Is it possible to make string S equal to B? Return true or false.

I completed it by only check if all unique characters from B exists in A or not and then return True or False.

Follow Up: What is the minimum number of times you need to concate if the given inputs are always True from the first question?
I approached O(n*m) solution. The interviewer was happy with this and told to write code for this approach.
I messed up when coding but at the end I could implement my idea. I checked and tested my code. Everything was fine.

Then I proposed another solution when I had only 2/3 mins which take O(max(n, m)) time complexity. And it was the best solution. He was happy taking my interview.

Comments (9)