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

0% completed

Vote For New Content
Out of curiosity, why is the time complexity O(N) and not O(N*K)

Rodney

Aug 1, 2022

Out of curiosity, why is the time complexity O(N) and not O(N*K)

1

0

Comments
Comments
M
Mohammad Khan3 years ago

I think it's O(N*K)

A
Austin McDaniel3 years ago

You're over simplifying runtime complexity analysis. Just because there is an inner loop doesn't mean you automatically multiply the runtime of an inner loop. Do a dry run. You'll see that the window_end traverses N elements. Easy for the outer loop and O(n) worst case....

On this page