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

0% completed

Vote For New Content
I'm wondering why the time complexity is O(N * M * Len) and not O(N * M)?

Alexander Bondarenko

Jan 9, 2022

I'm wondering why the time complexity is O(N * M * Len) and not O(N * M)?

2

0

Comments
Comments
S
Syed Hassan4 years ago

There is a substring function which calculates the substring from the given ranges of Len, and will run Len times for each calculation, which contributes to the time complexity. Here is the line which I am talking about

word = str.substring(next_word_index, next_word_i...

On this page