Python: Submission Time fluctuates

  • 0

    My submission times have been in the range 98-27. Is this due to my code or something with the OJ?

    Any advice is welcome.

    class Solution(object):
        def isPalindrome(self, s):
            :type s: str
            :rtype: bool
            s = s.strip(' ').lower()
            n = len(s)
            left, right = 0, n-1
            while left < right:
                while left < n and not s[left].isalnum(): 
                    left += 1
                    while right > -1 and not s[right].isalnum(): right -= 1
                    if left >= n or right < 0: return True
                    if s[left] != s[right]: return False
                    left += 1
                    right -= 1
            return True

    Thank you, Have a nice day.

  • 0

    Wow, 27 is fast. I think my fastest ever Python submission on LeetCode was 32 or 31. And the fastest in this problem's shown runtime statistic is 52. The Python times in general do vary quite a bit here, yes, but your 27 is a really really extreme case.

    You btw have an indentation error.

  • 0

    @StefanPochmann I should of clarified, I meant 27% - 98%. It seems like a big range of finishing times.

Log in to reply

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