Reverse integer Soluton
unknown
java
2 years ago
260 B
9
Indexable
class Solution {
public int reverse(int x) {
int reversedInt = 0;
while(x!=0){
int digit = x%10;
reversedInt = (reversedInt * 10) + digit;
x = x/10;
}
return reversedInt;
}
}Editor is loading...
Leave a Comment