go back / go searchO(logN)September 19, 2022i = n while i > 0: k = 2 + 2 i = i // 2 The value of i is cut in half each time through the loop so it will only take log n iterations.leet-code