diff --git a/leetcode 7.py b/leetcode 7.py new file mode 100644 index 0000000..7b25da3 --- /dev/null +++ b/leetcode 7.py @@ -0,0 +1,19 @@ +class Solution(object): + def reverse(self, x): + m=2147483647 + s=str(x) + if(x>=0): + s=s[::-1] + ans=int(s) + if(ans>m): ans=0 + return ans + else: + s=s[1:] + s=s[::-1] + ans=int(s) + if(ans>m): ans=0 + return -ans + """ + :type x: int + :rtype: int + """ \ No newline at end of file