FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/reverse-integer.java at master · wpande/leetcode · GitHub
wpande
leetcode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
reverse-integer.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (20 loc) · 428 Bytes
Breadcrumbs
leetcode
/
reverse-integer.java
Copy path
File metadata and controls
20 lines (20 loc) · 428 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public
class
Solution
{
public
int
reverse
(
int
x
) {
boolean
sign
=
true
;
if
(
x
<=
Integer
.
MIN_VALUE
)
return
0
;
if
(
x
<
0
){
sign
=
false
;
x
=-
x
;
}
long
res
=
0
;
while
(
x
!=
0
){
res
=
x
%
10
+
res
*
10
;
x
/=
10
;
}
if
(
res
>
Integer
.
MAX_VALUE
)
return
0
;
int
mres
=(
int
)
res
;
return
sign
?
mres
:-
mres
;
}
}
Back
|
FazBrowse Home
|
New Git URL