{"id":2244,"date":"2022-01-21T18:28:21","date_gmt":"2022-01-21T10:28:21","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2244"},"modified":"2022-01-21T18:28:22","modified_gmt":"2022-01-21T10:28:22","slug":"leetcodeday48","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday48\/","title":{"rendered":"leetcodeday48 &#8211;\u65cb\u8f6c\u56fe\u50cf"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a&nbsp;<em>n&nbsp;<\/em>\u00d7&nbsp;<em>n<\/em>&nbsp;\u7684\u4e8c\u7ef4\u77e9\u9635&nbsp;<code>matrix<\/code>&nbsp;\u8868\u793a\u4e00\u4e2a\u56fe\u50cf\u3002\u8bf7\u4f60\u5c06\u56fe\u50cf\u987a\u65f6\u9488\u65cb\u8f6c 90 \u5ea6\u3002<\/p>\n\n\n\n<p>\u4f60\u5fc5\u987b\u5728<strong><a href=\"https:\/\/baike.baidu.com\/item\/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;\u539f\u5730<\/a><\/strong>&nbsp;\u65cb\u8f6c\u56fe\u50cf\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u9700\u8981\u76f4\u63a5\u4fee\u6539\u8f93\u5165\u7684\u4e8c\u7ef4\u77e9\u9635\u3002<strong>\u8bf7\u4e0d\u8981&nbsp;<\/strong>\u4f7f\u7528\u53e6\u4e00\u4e2a\u77e9\u9635\u6765\u65cb\u8f6c\u56fe\u50cf\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\/08\/28\/mat1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>matrix = &#91;&#91;1,2,3],&#91;4,5,6],&#91;7,8,9]]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;7,4,1],&#91;8,5,2],&#91;9,6,3]]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/assets.leetcode.com\/uploads\/2020\/08\/28\/mat2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>matrix = &#91;&#91;5,1,9,11],&#91;2,4,8,10],&#91;13,3,6,7],&#91;15,14,12,16]]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;15,13,2,5],&#91;14,3,4,1],&#91;12,6,8,9],&#91;16,7,10,11]]<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>n == matrix.length == matrix[i].length<\/code><\/li><li><code>1 &lt;= n &lt;= 20<\/code><\/li><li><code>-1000 &lt;= matrix[i][j] &lt;= 1000<\/code><\/li><\/ul>\n\n\n\n<p>\u601d\u8def\uff1a\u5148\u8f6c\u7f6e\uff0c\u5728\u6bcf\u884c\u5012\u5e8f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc code=start\r\nclass Solution:\r\n    def rotate(self, matrix: List&#91;List&#91;int]]) -> None:\r\n        \"\"\"\r\n        Do not return anything, modify matrix in-place instead.\r\n        \"\"\"\r\n        mid=0\r\n        n=len(matrix)\r\n        for i  in range(n):\r\n            for j in range(i):\r\n                mid = matrix&#91;i]&#91;j]\r\n                matrix&#91;i]&#91;j] = matrix&#91;j]&#91;i]\r\n                matrix&#91;j]&#91;i] =  mid \r\n        for i  in range(n):\r\n            for j in range(n\/\/2):\r\n                mid=matrix&#91;i]&#91;j]\r\n                matrix&#91;i]&#91;j]=matrix&#91;i]&#91;n-j-1]\r\n                matrix&#91;i]&#91;n-j-1] = mid\r\n# @lc code=end<\/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-262.png\" alt=\"\" class=\"wp-image-2248\" width=\"516\" height=\"150\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-262.png 754w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-262-300x87.png 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a&nbsp;n&nbsp;\u00d7&nbsp;n&nbsp;\u7684\u4e8c\u7ef4\u77e9\u9635&nbsp;matrix&nbsp;\u8868 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday48\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday48 &#8211;\u65cb\u8f6c\u56fe\u50cf<\/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\/2244"}],"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=2244"}],"version-history":[{"count":5,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2244\/revisions"}],"predecessor-version":[{"id":2251,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2244\/revisions\/2251"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}