LeetCode 7

337 阅读1分钟

leetcode-cn.com/problems/re…

class Solution {
    fun reverse(x: Int): Int {
        kotlin.runCatching {
            if (x > 0) {
                return x.toString().reversed().toInt()
            } else {
                return -(-x).toString().reversed().toInt()
            }
        }
        return 0
    }
}