python sample code with re

  • 2
    import re
    class Solution(object):
        def myAtoi(self, str):
            r = re.match("[+-]?[0-9]+", str.strip())
            if not r:
                return 0
            y = int(
            if y < -2147483648:
                y = -2147483648 
            if y > 2147483647:
                y = 2147483647
            return y

  • 0
    This post is deleted!

  • 0

    fantastic, but I do no think you can use "int" type casting directly.

Log in to reply

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