def convertToTitle(self, n): if(n % 26 == 0): return (("A" * (n/26-1)) + "Z") else: return (("A" * int(n/26)) + chr(64 + n%26))
Wish I could help, but I'm in the same boat. I've got a similar solution that gets the same error.
I guess your solution is incorrect, please try the following test cases
convertToTile(52) = AZ which is correct
convertToTitle(53) = AAA is incorrect, the correct answer is BA
Another few examples
input your answer correct answer
54 AAB BB
701 AAAAAAAAAAAAAAAAAAAAAAAAAAY ZY
702 AAAAAAAAAAAAAAAAAAAAAAAAAAZ ZZ
Another test case OJ uses is 2147483647, your method hangs my desktop...anyway, the answer for this test case is 'FXSHRXW'
Please note that the title after AZ is BA, not AAA
Hope this helps.