Discuss / Python / 双指针,目测最快

双指针,目测最快

Topic source

大力拜

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-

def is_palindrome(n):
    strNum = str(n)
    left = 0
    right = len(strNum)-1
    while left < right:
        if strNum[left] != strNum[right]:
            return False
        left += 1
        right -= 1
    return True

  • 1

Reply