{"id":2235,"date":"2022-01-21T17:09:38","date_gmt":"2022-01-21T09:09:38","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2235"},"modified":"2022-01-21T18:02:17","modified_gmt":"2022-01-21T10:02:17","slug":"leetcodeday47","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday47\/","title":{"rendered":"leetcodeday47 &#8211;\u5168\u6392\u52172"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u53ef\u5305\u542b\u91cd\u590d\u6570\u5b57\u7684\u5e8f\u5217&nbsp;<code>nums<\/code>&nbsp;\uff0c<strong>\u6309\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u8fd4\u56de\u6240\u6709\u4e0d\u91cd\u590d\u7684\u5168\u6392\u5217\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;1,1,2]\n<strong>\u8f93\u51fa\uff1a<\/strong>\n&#91;&#91;1,1,2],\n &#91;1,2,1],\n &#91;2,1,1]]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;1,2,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;1,2,3],&#91;1,3,2],&#91;2,1,3],&#91;2,3,1],&#91;3,1,2],&#91;3,2,1]]<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>1 &lt;= nums.length &lt;= 8<\/code><\/li><li><code>-10 &lt;= nums[i] &lt;= 10<\/code><\/li><\/ul>\n\n\n\n<p>\u9012\u5f52\u6c42\u89e3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# &#91;46] \u5168\u6392\u5217\n#\n\n# @lc code=start\nclass Solution:\n    def permute(self, nums: List&#91;int]) -> List&#91;List&#91;int]]:\n        import copy\n        def subpermute(nums,index):\n            if index==0:\n               return &#91;&#91;nums&#91;0]]]\n            else:\n                rev=subpermute(nums,index-1)\n                res=list()\n                for i in range(len(rev)):\n                    #print(rev&#91;i])\n                    for j in range(len(rev&#91;i])+1):\n                        if j==len(rev&#91;i]) or rev&#91;i]&#91;j]!=nums&#91;index]:\n                            mid=copy.deepcopy(rev&#91;i])\n                        #print(mid)\n                            mid.insert(j,nums&#91;index])\n                            if mid not in res:\n                               res.append(mid)\n                        \n                return res\n        index=len(nums)-1\n        return subpermute(nums,index)<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-260.png\" alt=\"\" class=\"wp-image-2241\" width=\"407\" height=\"161\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-260.png 670w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-260-300x119.png 300w\" sizes=\"(max-width: 407px) 100vw, 407px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u53ef\u5305\u542b\u91cd\u590d\u6570\u5b57\u7684\u5e8f\u5217&nbsp;nums&nbsp;\uff0c\u6309\u4efb\u610f\u987a\u5e8f&nbsp;\u8fd4\u56de\u6240\u6709\u4e0d\u91cd\u590d\u7684\u5168\u6392\u5217\u3002  &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday47\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday47 &#8211;\u5168\u6392\u52172<\/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\/2235"}],"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=2235"}],"version-history":[{"count":6,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2235\/revisions"}],"predecessor-version":[{"id":2243,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2235\/revisions\/2243"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2235"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}