
[Leetcode] 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
簡單來說就是反轉數值,不過正負不變。
c++的code
1 |
int reverse(int x) { |
Runtime: 20 ms, faster than 25.65% of C++ online submissions for Reverse Integer.
雖然寫的簡單,但是跑得有點慢就是了。




近期评论