MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / reverse

Method reverse

src/com/blankj/easy/_0007/Solution.java:12–17  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

10 */
11public class Solution {
12 public int reverse(int x) {
13 long res = 0;
14 for (; x != 0; x /= 10)
15 res = res * 10 + x % 10;
16 return res > Integer.MAX_VALUE || res < Integer.MIN_VALUE ? 0 : (int) res;
17 }
18
19 public static void main(String[] args) {
20 Solution solution = new Solution();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected