반응형
leetcode.com/problems/reverse-integer/
solution
1
2
3
4
5
6
7
8
9
10
11
12
|
int reverse(int x) {
long long value = 0;
long long tx = x;
while (tx) {
value = value * 10 + tx % 10;
if (value < -2147483648 || value > 2147483647) return 0;
tx /= 10;
}
return value;
}
|
cs |
반응형
'코딩테스트 > Leetcode' 카테고리의 다른 글
Leetcode - [Easy]13. Roman to Integer (0) | 2021.03.14 |
---|---|
Leetcode - [Medium]3. Longest Substring Without Repeating Characters (0) | 2021.03.07 |
Leetcode - [Medium]2. Add Two Numbers (0) | 2021.03.04 |
Leetcode - [Easy]9. Palindrome Number (0) | 2021.03.04 |
Leetcode - [Easy]1. Two Sum (0) | 2021.03.04 |