complexitypractice
How do you sanity-check a complexity estimate?
Anonymous
Count the work inside each loop, then check how often each loop can run. Nested loops don't automatically mean O(n^2): if an inner pointer only moves forward across the whole run, its total work may be O(n).
0