is this a easy one?


  • 0
    1

    '''class Solution(object):
    def reverse(self, x):
    isMinus = x<0
    if x<0:
    x = -x
    LIMIT = 20
    price = 1
    paid = 0
    record = []
    i = 0
    for i in range(LIMIT):
    if x<price:
    break
    oneNum=(x-paid)/price%10;
    record.append(oneNum)
    paid += oneNum *price;
    price *= 10

        price = 1
        result=0
        for k in range(len(record)):
            j = len(record)-1-k
            result+=record[j]*price
            price *= 10
        if result > 2**31:
        	return 0
        if isMinus :
        	return -result
        else:
        	return result
    

    '''


Log in to reply
 

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