{"id":3091,"date":"2020-02-28T13:00:02","date_gmt":"2020-02-28T05:00:02","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=3091"},"modified":"2020-02-28T13:00:02","modified_gmt":"2020-02-28T05:00:02","slug":"%e3%80%90leetcode%e3%80%910073-%e7%9f%a9%e9%98%b5%e7%bd%ae%e9%9b%b6","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/algorithm\/3091\/","title":{"rendered":"\u3010LeetCode\u30110073 \u77e9\u9635\u7f6e\u96f6"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/set-matrix-zeroes\/\">https:\/\/leetcode-cn.com\/problems\/set-matrix-zeroes\/<\/a><\/p>\n\n\n<pre class=\"wp-block-preformatted\"># -*- coding:utf-8 -*-\n<em>\n<\/em>class Solution(object):\n    def setZeroes(self, matrix):\n        <em>\"\"\"\n        <\/em><strong><em>:type<\/em><\/strong><em> matrix: List[List[int]]\n        <\/em><strong><em>:rtype<\/em><\/strong><em>: None Do not return anything, modify matrix in-place instead.\n        \"\"\"\n        <\/em>x_list = []\n        y_list = []\n        # \u9996\u5148\u68c0\u67e50\u5143\u7d20\n        for i in range(len(matrix)):\n            for j in range(len(matrix[0])):\n                if matrix[i][j]==0:\n                    x_list.append(i)\n                    y_list.append(j)\n        # \u66f4\u6539\n        for i in range(len(matrix)):\n            for j in range(len(matrix[0])):\n                if i in x_list or j in y_list:\n                    matrix[i][j] = 0\n        return matrix\nif __name__ == '__main__':\n    matrix = [\n        [1, 1, 1],\n        [1, 0, 1],\n        [1, 1, 1]\n    ]\n    print(Solution().setZeroes(matrix))\n<\/pre>\n\n\n<p><strong>\u601d\u8def<\/strong>\uff1a\u9996\u5148\u68c0\u67e50\u5143\u7d20\u4f4d\u7f6e\uff0c\u8bb0\u5f55\u6240\u5728\u7684\u884c\u5217\uff0c\u7136\u540e\u518d\u6b21\u904d\u5386\uff0c\u5bf9\u51fa\u73b0\u5728\u6240\u5728\u884c\u6240\u5728\u5217\u4e2d\u7684\u5143\u7d20\u8d4b\u503c\u4e3a0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/leetcode-cn.com\/problems\/set-matrix-zeroes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"views":1589,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3091"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3091"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3091\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3091"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}