Turing Interview Question

Python program and time complexity