水题 Reverse Integer

public class Solution {
	int reverse(int x) {
		long result = 0;
		while(x!=0){
			result = result*10 + x%10 ;
			x/=10 ;
		}
		if(result>Integer.MAX_VALUE || result<Integer.MIN_VALUE ) return 0 ;
		else return (int)result ;
    }
}

  https://leetcode.com/problems/reverse-integer/

Reverse Integer 123 得 321 , -123 得 -321 , 溢出得 0 .

正在解zigzag convert , 这个题目评价是easy, 怎么我感觉好难,这个周末有时间去解解看.

时间: 2024-10-26 21:26:36

水题 Reverse Integer的相关文章

leetcode_26题——Reverse Integer(int型的表示范围)

Reverse Integer Total Accepted: 73207 Total Submissions: 281775My Submissions Question Solution Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers. Hide Tags Math Have you met this questi

leetcode第七题--Reverse Integer

Problem: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 终于什么都没参考就一次Accept了.可能是这题比较简单,同时自己也进步了一点点,leetcode就是这样给我们增加信心的吧. 我是这样想的,利用除10和模10两个操作,将每个数字分离在vec中,然后相应的乘以10的倍数输出就行.如果这个数在-10与10之间直接返回就好. 代码如下: class S

合天实验室,挑战练习。 reverse水题

关于reverse的水题.基础的. 题目链接:http://erange.heetian.com/CTFrace.html [1,dex2jar好用] 说是dex2jar好用,就猜到是apk了.改zip,解压出classes.de之后,用dex2jar,再用jd打开. 发现这么一段奇怪的字符数字,直接改成char表示,得到flag. f l a g { w 4 n n 4 _ j 4 r _ m y _ d 3 x } 去掉空格输入进去.ok. [2. int 3 断点稍微有点绕:pw1_pw2

LeetCode第[7]题(Java):Reverse Integer 标签:数学

题目:Reverse Integer 难度:Easy 题目内容: Given a 32-bit signed integer, reverse digits of an integer. Note:Assume we are dealing with an environment which could only hold integers within the 32-bit signed integer range. For the purpose of this problem, assum

Leetcode 7. Reverse Integer(水)

7. Reverse Integer Easy 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 Note: Assume we are dealing with an environment which could on

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

4.7-4.9补题+水题+高维前缀和

题目链接:51nod 1718 Cos的多项式  [数学] 题解: 2cosx=2cosx 2cos2x=(2cosx)^2-2 2cos3x=(2cosx)^3-3*(2cosx) 数归证明2cos(nx)能表示成关于2cosx的多项式,设为f(n) f(1)=x,f(2)=x^2-2(其中的x就是2cosx) 假设n=1~k时均成立(k>=3) 当n=k+1时 由cos((k+1)x)=cos(kx)cos(x)-sin(kx)sin(x) cos((k-1)x)=cos(kx)cos(x)

hdu 4274 Spy&amp;#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the