Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Couldn't this be done in O(N) where N is the length of the bigger string?

Ike Nwankwo

Mar 8, 2023

Couldn't this be done in O(N) where N is the length of the bigger string?

0

0

Comments
E
Ejike Nwude3 years ago

I don't think O(N) would be accurate since the algorithm iterates through both strings independently. In the worst case, this algorithm would iterate through both strings entirely and this would be as though the two strings were concatenated together hence the O(M+N) ti...