Reverse integer Soluton

mail@pastecode.io avatar
unknown
java
2 months ago
260 B
2
Indexable
Never
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;
    }
}
Leave a Comment