Big-O Time Complexity in Python Code