What is wasted in this example from the Cpp Core Guidelines?
strlen
is called every time the loop condition is checked, and takes O(n) time per call, so the total time for the loop is O(n^2).
strlen is calculated at every iteration of the loop.
strlen
is called every time the loop condition is checked, and takes O(n) time per call, so the total time for the loop is O(n^2).
strlen is calculated at every iteration of the loop.