leetcode 007 Reverse Integer
2016-04-19 19:57
447 查看
Total Accepted:
119423 Total Submissions:
378311 Difficulty: Easy
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Subscribe to see which companies asked this question
Have you met this question in a real interview?
119423 Total Submissions:
378311 Difficulty: Easy
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Subscribe to see which companies asked this question
Have you met this question in a real interview?
package com.archer; /** * * @author Archer * * 题意:高位换低位 低位换高位 * 题解: java int 32位 -2147483648----2147483648 * 考虑溢出的问题,可能原数不会溢出,但是转职后会溢出 如测试数据中的1534236469 */ public class Solution { publicint reverse(intx) { longans=0; //flag 0表示负数,1表示整数 while(x !=0){ ans = ans*10+ x%10; x /=10; if(ans >=2147483647 || ans <= -2147483647){ return0; } } return(int)ans; } }
相关文章推荐
- leetcode 179 Largest Number
- leetcode 24 Swap Nodes in Pairs
- leetcode 2 Add Two Numbers 方法1
- leetcode 2 Add Two Numbers 方法2
- leetcode----Longest Substring Without Repeating Characters
- [LeetCode]47 Permutations II
- [LeetCode]65 Valid Number
- [LeetCode]123 Best Time to Buy and Sell Stock III
- [LeetCode] String Reorder Distance Apart
- [LeetCode] Sliding Window Maximum
- [LeetCode] Find the k-th Smallest Element in the Union of Two Sorted Arrays
- [LeetCode] Determine If Two Rectangles Overlap
- [LeetCode] A Distance Maximizing Problem
- leetcode_linearList
- leetcode_linearList02
- 021-Merge Two Sorted Lists(合并两个排好序的单链表);leetcode
- LeetCode[Day 1] Two Sum 题解
- LeetCode[Day 2] Median of Two Sorted Arrays 题解
- LeetCode[Day 3] Longest Substring Without... 题解
- LeetCode [Day 4] Add Two Numbers 题解