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.
Lisa's Workbook
Lisa's Workbook
Sort by
recency
|
936 Discussions
|
Please Login in order to post a comment
Here is my c++ solution , you can watch the explanation here : https://youtu.be/3L-haDbsjAg
Instead of iterating over each problem, we can check if current_page falls within the range of problem_number to last_problem_on_page.
This approach reduces the time complexity for each page from O(k) to O(1) , where k is the maximum number of problems per page. Because it performs a single comparison per page rather than multiple comparisons for each problem on the page.
Haskell
O(n) where n number of pages