Leetcode 7. Median of Two Sorted Arrays The Solution of Python
2017-04-04 21:32
465 查看
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
Python:
速度不是很快,但是行数少,这道题简单,没啥好说的。
Example1: x = 123, return 321
Example2: x = -123, return -321
Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
Python:
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ x=int(str(x)[::-1]) if x>=0 else 0-int(str(abs(x))[::-1]) return 0 if x>2**31-1 or x<-2**31 else x
速度不是很快,但是行数少,这道题简单,没啥好说的。
相关文章推荐
- Leetcode 4. Median of Two Sorted Arrays The Solution of Python
- 4.Median of Two Sorted Arrays Leetcode Python
- Median of Two Sorted Arrays -- leetcode -- Python
- leetcode 日经贴,python code -Median of Two Sorted Arrays
- LeetCode 4 — Median of Two Sorted Arrays (C++ Java Python)
- LeetCode, Median of Two Sorted Arrays, Java Solution, O(m+n), O(log(m+n))
- [LeetCode]2 Median of Two Sorted Arrays (C++,Python实现)
- leetcode python - Median of Two Sorted Arrays
- 【LeetCode with Python】 Median of Two Sorted Arrays
- (python)leetcode刷题笔记04 Median of Two Sorted Arrays
- **Leetcode_median-of-two-sorted-arrays (c++ and python version)
- [leetcode]Median of Two Sorted Arrays @ Python
- [LeetCode]题解(python):004-Median of Two Sorted Arrays
- leetcode Median of Two Sorted Arrays python
- Leetcode 2. Add Two Numbers The Solution of Python and Javascript
- [LeetCode] Find the k-th Smallest Element in the Union of Two Sorted Arrays
- [Leetcode]4. Median of Two Sorted Arrays @python
- LeetCode-Median of Two Sorted Arrays
- LeetCode刷题笔录 Median Of Two Sorted Arrays
- LeetCode 4 - Median of Two Sorted Arrays