@@ -0,0 +1,638 @@
+#!/usr/bin/env python%0A# Reverse Integer https://oj.leetcode.com/problems/reverse-integer/%0A# Reverse digits of an integer.%0A# Example1: x = 123, return 321%0A# Example2: x = -123, return -321%0A%0A#Math%0A%0A# Xilin SUN%0A# Dec 7 2014%0A%0A# I guess this is the ugly way to do it%0A%0Aclass Solution:%0A%09# @return an integer%0A%09def reverse(self, x):%0A%09%09if x %3E 2147483646:%0A%09%09%09return 0%0A%09%09if x %3C -2147483647:%0A%09%09%09return 0%0A%09%09isPositive = True%0A%09%09if x %3C 0:%0A%09%09%09isPositive = False%0A%09%09%09x = -x%0A%09%09rev = 0%0A%09%09while x != 0:%0A%09%09%09rev = 10 * rev + x %25 10%0A%09%09%09x = x / 10%0A%09%09if rev %3E 2147483646:%0A%09%09%09return 0%0A%09%09if rev %3C -2147483647:%0A%09%09%09return 0%0A%09%09if isPositive:%0A%09%09%09return rev%0A%09%09return -rev%0A

Add ReverseInteger from LeetCode