Solution in Scala


  • 0
    U
    object Solution {
        def reverse(x: Int) = {
            try {
                if(x < 0 ){
                    (-x).toString.reverse.toInt.unary_-
                }else{
                    x.toString.reverse.toInt
                }
            } catch {
              case t: NumberFormatException => 0
            }
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.