Solution to problem on slide 4
Solution to problem on slide 5
Please complete the problem on the slide marked "Homework" (this problem).
Let me know if you have any questions about the slides or code in this post or need help debugging / working out a problem.
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x < 0:
return False
i = 0
while x >= 10 ** i:
i += 1
for j in range(i + 1):
big = j
small = i - j
bignum = x % (10 ** big)
smallnum = x / (10 ** small)
print(big, small, bignum, smallnum)
if x % 10 == 0:
return False
if bignum != smallnum:
return False
return True