{"id":2329,"date":"2022-01-24T10:21:31","date_gmt":"2022-01-24T02:21:31","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2329"},"modified":"2022-01-24T10:21:32","modified_gmt":"2022-01-24T02:21:32","slug":"leetcodeday64-2","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/24\/leetcodeday64-2\/","title":{"rendered":"leetcodeday64 &#8211;\u6709\u6548\u6570\u5b57"},"content":{"rendered":"\n<p><strong>\u6709\u6548\u6570\u5b57<\/strong>\uff08\u6309\u987a\u5e8f\uff09\u53ef\u4ee5\u5206\u6210\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ol><li>\u4e00\u4e2a&nbsp;<strong>\u5c0f\u6570<\/strong>&nbsp;\u6216\u8005&nbsp;<strong>\u6574\u6570<\/strong><\/li><li>\uff08\u53ef\u9009\uff09\u4e00\u4e2a&nbsp;<code>'e'<\/code>&nbsp;\u6216&nbsp;<code>'E'<\/code>&nbsp;\uff0c\u540e\u9762\u8ddf\u7740\u4e00\u4e2a&nbsp;<strong>\u6574\u6570<\/strong><\/li><\/ol>\n\n\n\n<p><strong>\u5c0f\u6570<\/strong>\uff08\u6309\u987a\u5e8f\uff09\u53ef\u4ee5\u5206\u6210\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ol><li>\uff08\u53ef\u9009\uff09\u4e00\u4e2a\u7b26\u53f7\u5b57\u7b26\uff08<code>'+'<\/code>&nbsp;\u6216&nbsp;<code>'-'<\/code>\uff09<\/li><li>\u4e0b\u8ff0\u683c\u5f0f\u4e4b\u4e00\uff1a<ol><li>\u81f3\u5c11\u4e00\u4f4d\u6570\u5b57\uff0c\u540e\u9762\u8ddf\u7740\u4e00\u4e2a\u70b9&nbsp;<code>'.'<\/code><\/li><li>\u81f3\u5c11\u4e00\u4f4d\u6570\u5b57\uff0c\u540e\u9762\u8ddf\u7740\u4e00\u4e2a\u70b9&nbsp;<code>'.'<\/code>&nbsp;\uff0c\u540e\u9762\u518d\u8ddf\u7740\u81f3\u5c11\u4e00\u4f4d\u6570\u5b57<\/li><li>\u4e00\u4e2a\u70b9&nbsp;<code>'.'<\/code>&nbsp;\uff0c\u540e\u9762\u8ddf\u7740\u81f3\u5c11\u4e00\u4f4d\u6570\u5b57<\/li><\/ol><\/li><\/ol>\n\n\n\n<p><strong>\u6574\u6570<\/strong>\uff08\u6309\u987a\u5e8f\uff09\u53ef\u4ee5\u5206\u6210\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ol><li>\uff08\u53ef\u9009\uff09\u4e00\u4e2a\u7b26\u53f7\u5b57\u7b26\uff08<code>'+'<\/code>&nbsp;\u6216&nbsp;<code>'-'<\/code>\uff09<\/li><li>\u81f3\u5c11\u4e00\u4f4d\u6570\u5b57<\/li><\/ol>\n\n\n\n<p>\u90e8\u5206\u6709\u6548\u6570\u5b57\u5217\u4e3e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li><code>[\"2\", \"0089\", \"-0.1\", \"+3.14\", \"4.\", \"-.9\", \"2e10\", \"-90E3\", \"3e+7\", \"+6e-1\", \"53.5e93\", \"-123.456e789\"]<\/code><\/li><\/ul>\n\n\n\n<p>\u90e8\u5206\u65e0\u6548\u6570\u5b57\u5217\u4e3e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li><code>[\"abc\", \"1a\", \"1e\", \"e3\", \"99e2.5\", \"--6\", \"-+3\", \"95a54e53\"]<\/code><\/li><\/ul>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>s<\/code>&nbsp;\uff0c\u5982\u679c&nbsp;<code>s<\/code>&nbsp;\u662f\u4e00\u4e2a&nbsp;<strong>\u6709\u6548\u6570\u5b57<\/strong>&nbsp;\uff0c\u8bf7\u8fd4\u56de&nbsp;<code>true<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u89e3\u6cd51:(\u5b98\u65b9\u7b54\u6848)<\/p>\n\n\n\n<p>\u786e\u5b9a\u6709\u9650\u72b6\u6001\u81ea\u52a8\u673a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" width=\"1024\" height=\"418\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-279-1024x418.png\" alt=\"\" class=\"wp-image-2331\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-279-1024x418.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-279-300x122.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-279-768x313.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-279.png 1113w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\r\r\n#\r\n# @lc app=leetcode.cn id=65 lang=python3\r\n#\r\n# &#91;65] \u6709\u6548\u6570\u5b57\r\n#\r\n\r\n# @lc code=start\r\nfrom enum import Enum\r\n\r\nclass Solution:\r\n    def isNumber(self, s: str) -> bool:\r\n        State = Enum(\"State\", &#91;\r\n            \"STATE_INITIAL\",\r\n            \"STATE_INT_SIGN\",\r\n            \"STATE_INTEGER\",\r\n            \"STATE_POINT\",\r\n            \"STATE_POINT_WITHOUT_INT\",\r\n            \"STATE_FRACTION\",\r\n            \"STATE_EXP\",\r\n            \"STATE_EXP_SIGN\",\r\n            \"STATE_EXP_NUMBER\",\r\n            \"STATE_END\"\r\n        ])\r\n        Chartype = Enum(\"Chartype\", &#91;\r\n            \"CHAR_NUMBER\",\r\n            \"CHAR_EXP\",\r\n            \"CHAR_POINT\",\r\n            \"CHAR_SIGN\",\r\n            \"CHAR_ILLEGAL\"\r\n        ])\r\n\r\n        def toChartype(ch: str) -> Chartype:\r\n            if ch.isdigit():\r\n                return Chartype.CHAR_NUMBER\r\n            elif ch.lower() == \"e\":\r\n                return Chartype.CHAR_EXP\r\n            elif ch == \".\":\r\n                return Chartype.CHAR_POINT\r\n            elif ch == \"+\" or ch == \"-\":\r\n                return Chartype.CHAR_SIGN\r\n            else:\r\n                return Chartype.CHAR_ILLEGAL\r\n        \r\n        transfer = {\r\n            State.STATE_INITIAL: {\r\n                Chartype.CHAR_NUMBER: State.STATE_INTEGER,\r\n                Chartype.CHAR_POINT: State.STATE_POINT_WITHOUT_INT,\r\n                Chartype.CHAR_SIGN: State.STATE_INT_SIGN\r\n            },\r\n            State.STATE_INT_SIGN: {\r\n                Chartype.CHAR_NUMBER: State.STATE_INTEGER,\r\n                Chartype.CHAR_POINT: State.STATE_POINT_WITHOUT_INT\r\n            },\r\n            State.STATE_INTEGER: {\r\n                Chartype.CHAR_NUMBER: State.STATE_INTEGER,\r\n                Chartype.CHAR_EXP: State.STATE_EXP,\r\n                Chartype.CHAR_POINT: State.STATE_POINT\r\n            },\r\n            State.STATE_POINT: {\r\n                Chartype.CHAR_NUMBER: State.STATE_FRACTION,\r\n                Chartype.CHAR_EXP: State.STATE_EXP\r\n            },\r\n            State.STATE_POINT_WITHOUT_INT: {\r\n                Chartype.CHAR_NUMBER: State.STATE_FRACTION\r\n            },\r\n            State.STATE_FRACTION: {\r\n                Chartype.CHAR_NUMBER: State.STATE_FRACTION,\r\n                Chartype.CHAR_EXP: State.STATE_EXP\r\n            },\r\n            State.STATE_EXP: {\r\n                Chartype.CHAR_NUMBER: State.STATE_EXP_NUMBER,\r\n                Chartype.CHAR_SIGN: State.STATE_EXP_SIGN\r\n            },\r\n            State.STATE_EXP_SIGN: {\r\n                Chartype.CHAR_NUMBER: State.STATE_EXP_NUMBER\r\n            },\r\n            State.STATE_EXP_NUMBER: {\r\n                Chartype.CHAR_NUMBER: State.STATE_EXP_NUMBER\r\n            },\r\n        }\r\n\r\n        st = State.STATE_INITIAL\r\n        for ch in s:\r\n            typ = toChartype(ch)\r\n            if typ not in transfer&#91;st]:\r\n                return False\r\n            st = transfer&#91;st]&#91;typ]\r\n        \r\n        return st in &#91;State.STATE_INTEGER, State.STATE_POINT, State.STATE_FRACTION, State.STATE_EXP_NUMBER, State.STATE_END]\r\n# @lc code=end\r\n\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u6548\u6570\u5b57\uff08\u6309\u987a\u5e8f\uff09\u53ef\u4ee5\u5206\u6210\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a \u4e00\u4e2a&nbsp;\u5c0f\u6570&nbsp;\u6216\u8005&nbsp;\u6574\u6570 \uff08\u53ef\u9009\uff09\u4e00\u4e2a&#038; &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/24\/leetcodeday64-2\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday64 &#8211;\u6709\u6548\u6570\u5b57<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2329"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2329"}],"version-history":[{"count":5,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2329\/revisions"}],"predecessor-version":[{"id":2335,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2329\/revisions\/2335"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2329"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}