What is wrong with this solution?


  • 0
    V

    class Solution:
    # @return an integer
    def reverse(self, x):
    strNumX=str(x)
    strNumY=""
    if strNumX[0]=="-":
    strNumY+="-"
    for i in range(len(strNumX)-1,0,-1):
    strNumY+=strNumX[i]
    else:
    for i in range(len(strNumX)-1,-1,-1):
    strNumY+=strNumX[i]

        return int(strNumY)

Log in to reply
 

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