MCPcopy
hub / github.com/qiyuangong/leetcode / reverse

Method reverse

java/007_Reverse_Integer.java:2–12  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int reverse(int x) {
3 if (x == 0) return 0;
4 long res = 0;
5 while (x != 0) {
6 res = res * 10 + x % 10;
7 if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE)
8 return 0;
9 x /= 10;
10 }
11 return (int) res;
12 }
13}

Callers 6

topKFrequentMethod · 0.45
createPalindromMethod · 0.45
licenseKeyFormattingMethod · 0.45
addStringsMethod · 0.45
reverseWordsMethod · 0.45
topKFrequentMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected