my code works in ideone but gives tle… help me reduce the runtime. I have used a single loop still it gives tle…

x=int(input())
b=[]*x
for i in range(0,x,1):
   c=int(input())
   if(c<=1000000 and c>=0):
      b.append(c)
      print("") 
      for j in range(0,x,1):
          a=b[j]
          f=a
          e=False
          while(e!=True):
                 f=f+1
                 e=True
                 l=0
                 a=str(f)
                 u=len(a)
                 l=int(u/2)
                 t=a[:l]
                 s=a[-(l):]
                if(t!= s):
                    e=False
          if(e==True):
                print(a)
  • created

    Jul '22
  • last reply

    Jul '22
  • 1

    reply

  • 549

    views

  • 2

    users

Like many others before, you’ve misread the constraints. It says K is not more than 1000000 digits.

So your current approach is not going to work.