Skip to content

009 Palindrome Number - Python #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 2, 2018
Merged

009 Palindrome Number - Python #79

merged 2 commits into from
Nov 2, 2018

Conversation

ashwek
Copy link
Member

@ashwek ashwek commented Nov 1, 2018

None.

@yanglbme yanglbme self-requested a review November 1, 2018 14:59
@yanglbme yanglbme added the need optimization Improvement request label Nov 1, 2018
Copy link
Member

@yanglbme yanglbme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format your code, please. See the following:

class Solution:
    def isPalindrome(self, num):
        """
        :type num: int
        :rtype: bool
        """
        if num < 0:
            return False
        
        temp = num
        rev = 0
        while temp > 0:
            rev = rev * 10 + temp % 10
            temp //= 10
        
        return rev == num

@ashwek
Copy link
Member Author

ashwek commented Nov 1, 2018

is it valid if i convert num to string & them check it ?

@yanglbme
Copy link
Member

yanglbme commented Nov 2, 2018

Yep, it is valid.

@yanglbme yanglbme merged commit 39222f0 into doocs:master Nov 2, 2018
@ashwek ashwek deleted the Palindrome branch November 2, 2018 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need optimization Improvement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants