This code is passing 8 test cases and in only one is it giving wrong answer.
What edge case am I missing out ?
Secondly besides, I haven’t using DP here and time complexity is O(max(str.size(), pattern.size()) while using DP it would have been O(str.size()*pattern.size()). Does it mean using DP in this question would have increased time complexity instead of reducing it ? Please explain