I have written this code in Python for the PALIN Problem ->
t = int(raw_input().strip())
for i in range(t):
a = raw_input()
a = str(int(a) + 1)
palin = ""
if (len(a) % 2 == 0):
reverseoffirst = []
mainStr = a
firsthalf = mainStr[0:len(a) / 2]
secondhalf = firsthalf[::-1]
palin = "".join(firsthalf) + "".join(secondhalf)
if (int(palin) < int(a)):
firsthalf = str(int(firsthalf) + 1)
secondhalf = firsthalf[::-1]
palin = "".join(firsthalf) + "".join(secondhalf)
else:
median = len(a) / 2
mainStr = a
if(median == 0):
palin = "11"
else:
firsthalf = mainStr[0:median]
secondhalf = firsthalf[::-1]
palin = "".join(firsthalf) + mainStr[median] + "".join(secondhalf)
if (int(palin) < int(a)):
lastvalue = int(mainStr[median]) + 1
if (lastvalue == 10):
firsthalf = str(int(firsthalf) + 1)
secondhalf = firsthalf[::-1]
palin = firsthalf + "0" + secondhalf
else:
palin = firsthalf + str(lastvalue) + secondhalf
print palin
This code is giving me a time limit exceeded error. If there is any testcase that it can not satisfy and if there is any other effective approach please do notify me!!!!