{"id":2544,"date":"2022-02-02T18:10:12","date_gmt":"2022-02-02T10:10:12","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2544"},"modified":"2022-02-02T18:16:24","modified_gmt":"2022-02-02T10:16:24","slug":"leetcodeday97","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/02\/02\/leetcodeday97\/","title":{"rendered":"leetcodeday97&#8211;\u4ea4\u9519\u5b57\u7b26\u4e32\uff08!\uff09"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e09\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>s1<\/code>\u3001<code>s2<\/code>\u3001<code>s3<\/code>\uff0c\u8bf7\u4f60\u5e2e\u5fd9\u9a8c\u8bc1&nbsp;<code>s3<\/code>&nbsp;\u662f\u5426\u662f\u7531&nbsp;<code>s1<\/code>&nbsp;\u548c&nbsp;<code>s2<\/code><em>&nbsp;<\/em><strong>\u4ea4\u9519&nbsp;<\/strong>\u7ec4\u6210\u7684\u3002<\/p>\n\n\n\n<p>\u4e24\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>s<\/code>&nbsp;\u548c&nbsp;<code>t<\/code>&nbsp;<strong>\u4ea4\u9519<\/strong>&nbsp;\u7684\u5b9a\u4e49\u4e0e\u8fc7\u7a0b\u5982\u4e0b\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5b57\u7b26\u4e32\u90fd\u4f1a\u88ab\u5206\u5272\u6210\u82e5\u5e72&nbsp;<strong>\u975e\u7a7a<\/strong>&nbsp;\u5b50\u5b57\u7b26\u4e32\uff1a<\/p>\n\n\n\n<ul><li><code>s = s<sub>1<\/sub>&nbsp;+ s<sub>2<\/sub>&nbsp;+ ... + s<sub>n<\/sub><\/code><\/li><li><code>t = t<sub>1<\/sub>&nbsp;+ t<sub>2<\/sub>&nbsp;+ ... + t<sub>m<\/sub><\/code><\/li><li><code>|n - m| &lt;= 1<\/code><\/li><li><strong>\u4ea4\u9519<\/strong>&nbsp;\u662f&nbsp;<code>s<sub>1<\/sub>&nbsp;+ t<sub>1<\/sub>&nbsp;+ s<sub>2<\/sub>&nbsp;+ t<sub>2<\/sub>&nbsp;+ s<sub>3<\/sub>&nbsp;+ t<sub>3<\/sub>&nbsp;+ ...<\/code>&nbsp;\u6216\u8005&nbsp;<code>t<sub>1<\/sub>&nbsp;+ s<sub>1<\/sub>&nbsp;+ t<sub>2<\/sub>&nbsp;+ s<sub>2<\/sub>&nbsp;+ t<sub>3<\/sub>&nbsp;+ s<sub>3<\/sub>&nbsp;+ ...<\/code><\/li><\/ul>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><code>a + b<\/code>&nbsp;\u610f\u5473\u7740\u5b57\u7b26\u4e32&nbsp;<code>a<\/code>&nbsp;\u548c&nbsp;<code>b<\/code>&nbsp;\u8fde\u63a5\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/assets.leetcode.com\/uploads\/2020\/09\/02\/interleave.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>s1 = \"aabcc\", s2 = \"dbbca\", s3 = \"aadbbcbcac\"\n<strong>\u8f93\u51fa\uff1a<\/strong>true\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>s1 = \"aabcc\", s2 = \"dbbca\", s3 = \"aadbbbaccc\"\n<strong>\u8f93\u51fa\uff1a<\/strong>false\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>s1 = \"\", s2 = \"\", s3 = \"\"<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" width=\"1024\" height=\"655\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-14-1024x655.png\" alt=\"\" class=\"wp-image-2545\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-14-1024x655.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-14-300x192.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-14-768x491.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-14.png 1263w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;97] \u4ea4\u9519\u5b57\u7b26\u4e32\r\n#\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def isInterleave(self, s1: str, s2: str, s3: str) -> bool:\r\n        len1=len(s1)\r\n        len2=len(s2)\r\n        len3=len(s3)\r\n        if(len1+len2!=len3):\r\n            return False\r\n        dp=&#91;&#91;False]*(len2+1) for i in range(len1+1)]\r\n        dp&#91;0]&#91;0]=True\r\n        for i in range(1,len1+1):\r\n            dp&#91;i]&#91;0]=(dp&#91;i-1]&#91;0] and s1&#91;i-1]==s3&#91;i-1])\r\n        for i in range(1,len2+1):\r\n            dp&#91;0]&#91;i]=(dp&#91;0]&#91;i-1] and s2&#91;i-1]==s3&#91;i-1])\r\n        for i in range(1,len1+1):\r\n            for j in range(1,len2+1):\r\n                dp&#91;i]&#91;j]=(dp&#91;i]&#91;j-1] and s2&#91;j-1]==s3&#91;i+j-1]) or (dp&#91;i-1]&#91;j] and s1&#91;i-1]==s3&#91;i+j-1])\r\n        return dp&#91;-1]&#91;-1]\r\n# @lc code=end\r\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"911\" height=\"245\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-15.png\" alt=\"\" class=\"wp-image-2549\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-15.png 911w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-15-300x81.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-15-768x207.png 768w\" sizes=\"(max-width: 911px) 100vw, 911px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e09\u4e2a\u5b57\u7b26\u4e32&nbsp;s1\u3001s2\u3001s3\uff0c\u8bf7\u4f60\u5e2e\u5fd9\u9a8c\u8bc1&nbsp;s3&nbsp;\u662f\u5426\u662f\u7531&nbsp;s1&#038; &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/02\/02\/leetcodeday97\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday97&#8211;\u4ea4\u9519\u5b57\u7b26\u4e32\uff08!\uff09<\/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\/2544"}],"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=2544"}],"version-history":[{"count":5,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2544\/revisions"}],"predecessor-version":[{"id":2552,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2544\/revisions\/2552"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2544"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}