Can you help me in MAXNUM3 almost same code in python3 shows TLE

Here is my solution CodeChef: Practical coding for everyone it is similar to CodeChef: Practical coding for everyone but mine gets TLE

 temp_a  = a[0:i] + a[(i+1):len(a)]

Can you once confirm the complexity of the above operation? I think its O(N) in itself and gives your code complexity of O({N}^{2}) in itself.

Also See this statement in your code:
for i in range(len(a)) :
function len is itself linear in nature. Every time in for loop iteration len function is evaluated to check the limit and hence, time complexity is getting increased by a factor n,which ultimately slows down your program.
Its a common mistake, just store length in a variable before iterating and then use that variable inside loop.
Even after keeping variable for len function, your program timed out.I compared both the solutions and logic is more or less same.One thing which you are doing is unnecessary typecasting of strings to int, which overkill.
Just use it as string variable for comparison. Here is the link for your ACed solution.

2 Likes

yes the complexity of the statement is O(n)

Thank You :slight_smile: