{"id":2380,"date":"2022-01-25T15:27:48","date_gmt":"2022-01-25T07:27:48","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2380"},"modified":"2022-01-25T15:27:50","modified_gmt":"2022-01-25T07:27:50","slug":"leetcodeday74","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/25\/leetcodeday74\/","title":{"rendered":"leetcodeday74 &#8211;\u641c\u7d22\u4e8c\u7ef4\u77e9\u9635"},"content":{"rendered":"\n<p>\u7f16\u5199\u4e00\u4e2a\u9ad8\u6548\u7684\u7b97\u6cd5\u6765\u5224\u65ad&nbsp;<code>m x n<\/code>&nbsp;\u77e9\u9635\u4e2d\uff0c\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u76ee\u6807\u503c\u3002\u8be5\u77e9\u9635\u5177\u6709\u5982\u4e0b\u7279\u6027\uff1a<\/p>\n\n\n\n<ul><li>\u6bcf\u884c\u4e2d\u7684\u6574\u6570\u4ece\u5de6\u5230\u53f3\u6309\u5347\u5e8f\u6392\u5217\u3002<\/li><li>\u6bcf\u884c\u7684\u7b2c\u4e00\u4e2a\u6574\u6570\u5927\u4e8e\u524d\u4e00\u884c\u7684\u6700\u540e\u4e00\u4e2a\u6574\u6570\u3002<\/li><\/ul>\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\/10\/05\/mat.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>matrix = &#91;&#91;1,3,5,7],&#91;10,11,16,20],&#91;23,30,34,60]], target = 3\n<strong>\u8f93\u51fa\uff1a<\/strong>true<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;74] \u641c\u7d22\u4e8c\u7ef4\u77e9\u9635\r\n#\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def searchMatrix(self, matrix: List&#91;List&#91;int]], target: int) -> bool:\r\n        def twoserch(nums,i,j,target):\r\n            # i=0\r\n            # j=len(nums)-1\r\n            if nums&#91;0]==target:\r\n                return True\r\n            mid=(i+j)\/\/2\r\n            while i&lt;j-1:\r\n                mid=(i+j)\/\/2\r\n                if nums&#91;mid]==target:\r\n                    return True\r\n                elif nums&#91;mid]&lt;target:\r\n                    i=mid\r\n                else:\r\n                    j=mid\r\n            return False\r\n\r\n\r\n        j=-1\r\n        for i in range(len(matrix)):\r\n            if target&lt;matrix&#91;i]&#91;-1]:\r\n                j=i\r\n                break\r\n            elif target==matrix&#91;i]&#91;-1]:\r\n                return True\r\n        if j == -1:\r\n            return False\r\n        else:\r\n            lens=len(matrix&#91;j])\r\n            return twoserch(matrix&#91;j],0,lens-1,target)\r\n# @lc code=end<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"899\" height=\"241\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-290.png\" alt=\"\" class=\"wp-image-2381\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-290.png 899w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-290-300x80.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-290-768x206.png 768w\" sizes=\"(max-width: 899px) 100vw, 899px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7f16\u5199\u4e00\u4e2a\u9ad8\u6548\u7684\u7b97\u6cd5\u6765\u5224\u65ad&nbsp;m x n&nbsp;\u77e9\u9635\u4e2d\uff0c\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u76ee\u6807\u503c\u3002\u8be5\u77e9\u9635\u5177\u6709\u5982\u4e0b\u7279\u6027\uff1a \u6bcf &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/25\/leetcodeday74\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday74 &#8211;\u641c\u7d22\u4e8c\u7ef4\u77e9\u9635<\/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\/2380"}],"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=2380"}],"version-history":[{"count":1,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2380\/revisions"}],"predecessor-version":[{"id":2382,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2380\/revisions\/2382"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2380"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}