We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
why is complexity O( QN)? i think it's O(N). I guess the worst case is 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 ... where Q=5. Only at 5, we need 4 comparisions, because 4 3 2 1 are in the queue, but we only have N/Q 5, and thus (Q-1)* N/Q is about N. What do you think?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Queries with Fixed Length
You are viewing a single comment's thread. Return to all comments →
why is complexity O( QN)? i think it's O(N). I guess the worst case is 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 ... where Q=5. Only at 5, we need 4 comparisions, because 4 3 2 1 are in the queue, but we only have N/Q 5, and thus (Q-1)* N/Q is about N. What do you think?