{"id":39453,"date":"2025-05-23T18:13:43","date_gmt":"2025-05-23T10:13:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/39453.html"},"modified":"2025-05-23T18:13:43","modified_gmt":"2025-05-23T10:13:43","slug":"%e8%a7%a3%e5%86%b3leetcode%e7%ac%ac3548%e9%a2%98-%e7%ad%89%e5%92%8c%e7%9f%a9%e9%98%b5%e5%88%86%e5%89%b2ii","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/39453.html","title":{"rendered":"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II"},"content":{"rendered":"<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">3548.\u7b49\u548c\u77e9\u9635\u5206\u5272II<\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u96be\u5ea6&#xff1a;\u56f0\u96be<\/h4>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u95ee\u9898\u63cf\u8ff0&#xff1a;<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u7ed9\u4f60\u4e00\u4e2a\u7531\u6b63\u6574\u6570\u7ec4\u6210\u7684mxn\u77e9\u9635grid\u3002\u4f60\u7684\u4efb\u52a1\u662f\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u4e00\u6761\u6c34\u5e73\u6216\u4e00\u6761\u5782\u76f4\u5206\u5272\u7ebf\u5c06\u77e9\u9635\u5206\u5272\u6210\u4e24\u90e8\u5206&#xff0c;\u4f7f\u5f97&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5206\u5272\u540e\u5f62\u6210\u7684\u6bcf\u4e2a\u90e8\u5206\u90fd\u662f\u975e\u7a7a\u7684\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4e24\u4e2a\u90e8\u5206\u4e2d\u6240\u6709\u5143\u7d20\u7684\u548c\u76f8\u7b49&#xff0c;\u6216\u8005\u603b\u5171\u6700\u591a\u79fb\u9664\u4e00\u4e2a\u5355\u5143\u683c&#xff08;\u4ece\u5176\u4e2d\u4e00\u4e2a\u90e8\u5206\u4e2d&#xff09;\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u4f7f\u5b83\u4eec\u76f8\u7b49\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5982\u679c\u79fb\u9664\u67d0\u4e2a\u5355\u5143\u683c&#xff0c;\u5269\u4f59\u90e8\u5206\u5fc5\u987b\u4fdd\u6301\u8fde\u901a\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5982\u679c\u5b58\u5728\u8fd9\u6837\u7684\u5206\u5272&#xff0c;\u8fd4\u56detrue&#xff1b;\u5426\u5219&#xff0c;\u8fd4\u56defalse\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6ce8\u610f&#xff1a;\u5982\u679c\u4e00\u4e2a\u90e8\u5206\u4e2d\u7684\u6bcf\u4e2a\u5355\u5143\u683c\u90fd\u53ef\u4ee5\u901a\u8fc7\u5411\u4e0a\u3001\u5411\u4e0b\u3001\u5411\u5de6\u6216\u5411\u53f3\u79fb\u52a8\u5230\u8fbe\u540c\u4e00\u90e8\u5206\u4e2d\u7684\u5176\u4ed6\u5355\u5143\u683c&#xff0c;\u5219\u8ba4\u4e3a\u8fd9\u4e00\u90e8\u5206\u662f\u8fde\u901a\u7684\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u793a\u4f8b1&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u5165&#xff1a;grid&#061;[[1,4],[2,3]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u51fa&#xff1a;true<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u89e3\u91ca&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u7b2c0\u884c\u548c\u7b2c1\u884c\u4e4b\u95f4\u8fdb\u884c\u6c34\u5e73\u5206\u5272&#xff0c;\u7ed3\u679c\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u4e3a1&#043;4&#061;5\u548c2&#043;3&#061;5&#xff0c;\u76f8\u7b49\u3002\u56e0\u6b64\u7b54\u6848\u662ftrue\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u793a\u4f8b2&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u5165&#xff1a;grid&#061;[[1,2],[3,4]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u51fa&#xff1a;true<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u89e3\u91ca&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u7b2c0\u5217\u548c\u7b2c1\u5217\u4e4b\u95f4\u8fdb\u884c\u5782\u76f4\u5206\u5272&#xff0c;\u7ed3\u679c\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u4e3a1&#043;3&#061;4\u548c2&#043;4&#061;6\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u4ece\u53f3\u4fa7\u90e8\u5206\u79fb\u96642&#xff08;6-2&#061;4&#xff09;&#xff0c;\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u76f8\u7b49&#xff0c;\u5e76\u4e14\u4e24\u90e8\u5206\u4fdd\u6301\u8fde\u901a\u3002\u56e0\u6b64\u7b54\u6848\u662ftrue\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u793a\u4f8b3&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u5165&#xff1a;grid&#061;[[1,2,4],[2,3,5]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u51fa&#xff1a;false<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u89e3\u91ca&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5728\u7b2c0\u884c\u548c\u7b2c1\u884c\u4e4b\u95f4\u8fdb\u884c\u6c34\u5e73\u5206\u5272&#xff0c;\u7ed3\u679c\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u4e3a1&#043;2&#043;4&#061;7\u548c2&#043;3&#043;5&#061;10\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u901a\u8fc7\u4ece\u5e95\u90e8\u90e8\u5206\u79fb\u96643&#xff08;10-3&#061;7&#xff09;&#xff0c;\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u76f8\u7b49&#xff0c;\u4f46\u5e95\u90e8\u90e8\u5206\u4e0d\u518d\u8fde\u901a&#xff08;\u5206\u88c2\u4e3a[2]\u548c[5]&#xff09;\u3002\u56e0\u6b64\u7b54\u6848\u662ffalse\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u793a\u4f8b4&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u5165&#xff1a;grid&#061;[[4,1,8],[3,2,6]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8f93\u51fa&#xff1a;false<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u89e3\u91ca&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4e0d\u5b58\u5728\u6709\u6548\u7684\u5206\u5272&#xff0c;\u56e0\u6b64\u7b54\u6848\u662ffalse\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u63d0\u793a&#xff1a;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">1&lt;&#061;m&#061;&#061;grid.length&lt;&#061;105<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">1&lt;&#061;n&#061;&#061;grid[i].length&lt;&#061;105<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">2&lt;&#061;m*n&lt;&#061;105<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">1&lt;&#061;grid[i][j]&lt;&#061;105<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u95ee\u9898\u5206\u6790&#xff1a;<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u8fd9\u4e2a\u95ee\u9898\u7684\u5904\u7406&#xff0c;\u5176\u5b9e\u5c31\u662f\u628a\u4e00\u4e2a\u7ed9\u5b9a\u7684\u77e9\u9635\u6309\u884c\u548c\u5217\u8fdb\u884c\u62c6\u5206&#xff0c;\u5f97\u5230\u62c6\u5206\u51fa\u6765\u7684\u4e24\u4e2a\u5b50\u77e9\u9635&#xff0c;\u518d\u628a\u5b83\u4eec\u7684\u5143\u7d20\u548c\u6c42\u51fa\u6765&#xff0c;\u5148\u6bd4\u8f83\u548c\u503c\u662f\u5426\u76f8\u7b49&#xff0c;\u5982\u679c\u76f8\u7b49\u8fd4\u56deTrue&#xff0c;\u5982\u679c\u4e0d\u76f8\u7b49&#xff0c;\u518d\u627e\u51fa\u548c\u503c\u5927\u7684\u90a3\u4e2a\u5b50\u77e9\u9635&#xff0c;\u5bf9\u5b83\u6309\u987a\u5e8f\u8fdb\u884c\u53bb\u6389\u4e00\u4e2a\u5143\u7d20\u4e4b\u540e\u6c42\u548c\u7684\u5904\u7406&#xff0c;\u5f97\u5230\u4e00\u4e2a\u548c\u503c\u7684\u5217\u8868&#xff0c;\u7136\u540e\u6bd4\u8f83\u8f83\u5c0f\u7684\u90a3\u4e2a\u548c\u503c\u4e0e\u5217\u8868\u4e2d\u7684\u54ea\u4e2a\u503c\u76f8\u7b49&#xff0c;\u5982\u679c\u6709\u76f8\u7b49\u7684\u60c5\u51b5&#xff0c;\u518d\u68c0\u67e5\u53bb\u6389\u90a3\u4e2a\u5143\u7d20\u4e4b\u540e&#xff0c;\u77e9\u9635\u662f\u5426\u8fde\u901a&#xff0c;\u5982\u679c\u68c0\u67e5\u662f\u8fde\u901a\u7684&#xff0c;\u5219\u8fd4\u56deTrue&#xff0c;\u5426\u5219\u7ee7\u7eed\u6bd4\u8f83&#xff0c;\u7ee7\u7eed\u5206\u5272\u5b50\u77e9\u9635\u3002\u5982\u679c\u6309\u884c\u548c\u5217\u8fdb\u884c\u5206\u5272\u5e76\u8fdb\u884c\u6bd4\u8f83\u90fd\u6ca1\u6709\u76f8\u7b49\u6216\u76f8\u7b49\u5e76\u8fde\u901a\u7684\u60c5\u51b5&#xff0c;\u6700\u540e\u8fd4\u56deFalse\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u4e3a\u6b64\u8bbe\u8ba1\u4ee5\u4e0b\u51fd\u6570\u5b9e\u73b0&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u51fd\u6570is_connected(a,i,j)&#xff0c;\u7528\u4e8e\u68c0\u67e5\u77e9\u9635a\u4e2d\u53bb\u6389\u5750\u6807\u4e3a(i,j)\u7684\u5143\u7d20\u4e4b\u540e&#xff0c;\u77e9\u9635\u662f\u5426\u8fde\u901a&#xff0c;\u5982\u679c\u8fde\u901a&#xff0c;\u8fd4\u56deTrue&#xff0c;\u5426\u5219\u8fd4\u56deFalse\u3002\u5f53\u884c\u6570\u6216\u5217\u6570\u5728\u5927\u4e8e\u7b492\u65f6&#xff0c;\u4e0d\u7ba1\u4f60\u53bb\u6389\u54ea\u4e2a\u5143\u7d20&#xff0c;\u5217\u8868\u90fd\u662f\u8fde\u901a\u7684&#xff0c;\u5f53\u53ea\u6709\u4e00\u884c&#xff08;\u6216\u5217&#xff09;\u65f6&#xff0c;\u5217\u503c&#xff08;\u6216\u884c\u503c&#xff09;\u5982\u679c\u5904\u5728\u4e2d\u95f4\u4f4d\u7f6e\u65f6&#xff0c;\u5217\u8868\u4e3a\u4e0d\u8fde\u901a\u72b6\u6001&#xff0c;\u5904\u5728\u4e24\u7aef\u65f6\u4e3a\u8fde\u901a\u72b6\u6001\u3002<\/li>\n<li style=\"text-align:justify\">\u51fd\u6570get_sum_array(s)&#xff0c;\u7528\u4e8e\u8ba1\u7b97\u77e9\u9635s\u4e2d\u6240\u6709\u5143\u7d20\u4e4b\u548c\u5e76\u8fd4\u56de\u3002<\/li>\n<li style=\"text-align:justify\">\u51fd\u6570\u00a0get_sum_array_lost_one(a)&#xff0c;\u7528\u4e8e\u8ba1\u7b97\u77e9\u9635a\u6309\u987a\u5e8f\u53bb\u6389\u5404\u4e2a\u5143\u7d20\u4e4b\u540e&#xff0c;\u5269\u4f59\u5143\u7d20\u4e4b\u548c\u7684\u5217\u8868<\/li>\n<li style=\"text-align:justify\">\u51fd\u6570def split_array_row(s,i)\u548csplit_array_col(s,i)\u5b9e\u73b0\u6309\u884c\u6570\u548c\u5217\u6570\u5bf9\u77e9\u9635s\u8fdb\u884c\u5206\u5272&#xff0c;\u5e76\u8fd4\u56de\u5206\u5272\u4e4b\u540e\u7684\u4e24\u4e2a\u5b50\u77e9\u9635\u3002<\/li>\n<li style=\"text-align:justify\">\u6700\u540e\u7684\u51fd\u6570split_array_equal_sum(s)\u5219\u5bf9\u77e9\u9635s\u6309\u884c\u548c\u5217\u8fdb\u884c\u5206\u5272\u5904\u7406&#xff0c;\u8ba1\u7b97\u5b50\u77e9\u9635\u5143\u7d20\u548c&#xff0c;\u7136\u540e\u5224\u65ad\u548c\u503c\u662f\u5426\u76f8\u7b49\u6216\u548c\u503c\u5c0f\u7684\u662f\u5426\u4e0e\u53bb\u6389\u4e00\u4e2a\u5143\u7d20\u4e4b\u540e\u7684\u67d0\u4e00\u4e2a\u548c\u503c\u76f8\u7b49\u4e14\u8fde\u901a\u60c5\u51b5\u8fdb\u884c\u5224\u65ad&#xff0c;\u8fd4\u56de\u76f8\u5e94\u7684\u7ed3\u679c\u3002<\/li>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u7a0b\u5e8f\u5982\u4e0b&#xff1a;<\/h4>\n<p>#\u5224\u65ad\u5728\u4e00\u4e2a\u7f51\u683c\u4e2d&#xff0c;\u9664\u4e86\u70b9&#xff08;i&#xff0c;j&#xff09;\u4e4b\u5916\u7684\u70b9\u662f\u5426\u8fde\u901a&#xff0c;\u5982\u679c\u662f\u8fde\u901a&#xff0c;\u8fd4\u56deTrue&#xff0c;\u5426\u5219\u8fd4\u56deFalse<br \/>\ndef is_connected(a,i,j):<br \/>\n    n&#061;len(a)<br \/>\n    m&#061;len(a[0])<br \/>\n    # print(&#039;n,m&#061;&#039;,n,m)<br \/>\n    if n&#061;&#061;1 and 0&lt;j&lt;m-1:<br \/>\n        return False<br \/>\n    elif m&#061;&#061;1 and 0&lt;i&lt;n-1:<br \/>\n        return False<br \/>\n    else:<br \/>\n        return True<\/p>\n<p>#\u8ba1\u7b97\u4e00\u4e2a\u77e9\u9635\u5143\u7d20\u4e4b\u548c&#xff0c;\u5e76\u8fd4\u56de<br \/>\ndef get_sum_array(s):<br \/>\n    my_sum&#061;0<br \/>\n    for i in s:<br \/>\n        my_sum&#061;my_sum&#043;sum(i)<br \/>\n    return my_sum<\/p>\n<p>#\u8ba1\u7b97\u4e00\u4e2a\u77e9\u9635\u5143\u7d20\u4e4b\u548c&#xff0c;\u7136\u540e\u53bb\u6389\u4e00\u4e2a\u5143\u7d20\u4e4b\u540e&#xff0c;\u8fd4\u56de\u5176\u4f59\u5143\u7d20\u53ef\u80fd\u7684\u548c\u7684\u5217\u8868<br \/>\ndef get_sum_array_lost_one(a):<br \/>\n    s&#061;get_sum_array(a)<br \/>\n    n&#061;len(a)<br \/>\n    m&#061;len(a[0])<br \/>\n    b&#061;[]<br \/>\n    for i in range(n):<br \/>\n        for j in range(m):<br \/>\n            b.append([s-a[i][j],i,j])<br \/>\n    return b<\/p>\n<p>#\u6309\u884c\u5206\u5272\u77e9\u9635&#xff0c;i\u662f\u884c\u6570<br \/>\ndef split_array_row(s,i):<br \/>\n    return s[:i],s[i:]<\/p>\n<p>#\u6309\u5217\u5206\u5272\u77e9\u9635&#xff0c;i\u662f\u5217\u6570<br \/>\ndef split_array_col(s,i):<br \/>\n    left&#061;[x[:i] for x in s]<br \/>\n    right&#061;[x[i:] for x in s]<br \/>\n    return left,right<\/p>\n<p>#\u5bf9\u4e8e\u4e00\u4e2amxn\u77e9\u9635&#xff0c;\u5224\u65ad\u662f\u5426\u5b58\u5728\u4e00\u6761\u6c34\u5e73\u6216\u7ad6\u76f4\u7ebf&#xff0c;\u80fd\u591f\u5c06\u77e9\u9635\u5206\u5272\u6210\u548c\u76f8\u7b49\u7684\u4e24\u90e8\u5206<br \/>\ndef split_array_equal_sum(s):<br \/>\n    m&#061;len(s)<br \/>\n    n&#061;len(s[0])<br \/>\n    for i in range(1,m):<br \/>\n        up,down&#061;split_array_row(s,i)<br \/>\n        u &#061; get_sum_array(up)<br \/>\n        d &#061; get_sum_array(down)<br \/>\n        if u&#061;&#061;d:<br \/>\n            return True<br \/>\n        else:<br \/>\n            up, down &#061; (up, down) if u &gt; d else (down, up)<br \/>\n            t&#061;get_sum_array_lost_one(up)<br \/>\n            down&#061;get_sum_array(down)<br \/>\n            for i in t:<br \/>\n                if down&#061;&#061;i[0] and is_connected(up,i[1],i[2]):<br \/>\n                    return True<br \/>\n                else:<br \/>\n                    continue<br \/>\n    for j in range(1,n):<br \/>\n        left,right&#061;split_array_col(s,j)<br \/>\n        l &#061; get_sum_array(left)<br \/>\n        r &#061; get_sum_array(right)<br \/>\n        if l&#061;&#061;r:<br \/>\n            return True<br \/>\n        else:<br \/>\n            left, right &#061; (left, right) if l &gt; r else (right, left)<br \/>\n            t&#061;get_sum_array_lost_one(left)<br \/>\n            right&#061;get_sum_array(right)<br \/>\n            for i in t:<br \/>\n                if right&#061;&#061;i[0] and is_connected(left,i[1],i[2]):<br \/>\n                    return True<br \/>\n                else:<br \/>\n                    continue<br \/>\n    else:<br \/>\n        return False<\/p>\n<p>#\u4e3b\u7a0b\u5e8f<br \/>\ngrid&#061;eval(input(&#039;pls input grid&#061;&#039;))<br \/>\nprint(split_array_equal_sum(grid)) <\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u4e00<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[1,2,3]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">True<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u4e8c<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[5],[2],[3]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">True<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u4e09<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[1,2,3,4]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">True<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u56db<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[2,4],[1,5]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">True<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u4e94<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[2,3,4],[4,5,6],[7,8,10]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">False<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u8fd0\u884c\u5b9e\u4f8b\u516d<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">pls input grid&#061;[[2,3,4],[4,5,6],[7,8,6]]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">True<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u5bf9\u95ee\u9898\u8fdb\u884c\u5207\u5272&#xff0c;\u51c6\u786e\u628a\u63e1\u6bcf\u90e8\u5206\u529f\u80fd&#xff0c;\u7ec6\u5fc3\u5b9e\u73b0\u5e76\u7ec4\u5408&#xff0c;\u95ee\u9898\u89e3\u51b3\u72b9\u5982\u51b0\u96ea\u4e4b\u6d88\u878d&#xff0c;\u5fc3\u5883\u5982\u5929\u7a7a\u4e4b\u6717\u6717\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb254\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u5173\u4e8e\u77e9\u9635\u5206\u5272\u7684\u7b97\u6cd5\u95ee\u9898\uff0c\u8981\u6c42\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6216\u5782\u76f4\u5206\u5272\u7ebf\u5c06\u77e9\u9635\u5206\u6210\u4e24\u90e8\u5206\uff0c\u4f7f\u5f97\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u76f8\u7b49\uff0c\u6216\u8005\u6700\u591a\u79fb\u9664\u4e00\u4e2a\u5355\u5143\u683c\u540e\u4f7f\u5b83\u4eec\u76f8\u7b49\uff0c\u5e76\u4e14\u4fdd\u6301\u8fde\u901a\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u63cf\u8ff0\u4e86\u95ee\u9898\u7684\u80cc\u666f\u3001\u793a\u4f8b\u3001\u5206\u6790\u601d\u8def\u4ee5\u53ca\u5b9e\u73b0\u65b9\u6cd5\u3002\u901a\u8fc7\u8bbe\u8ba1\u591a\u4e2a\u8f85\u52a9\u51fd\u6570\uff0c\u5982\u68c0\u67e5\u8fde\u901a\u6027\u3001\u8ba1\u7b97\u77e9\u9635\u548c\u3001\u6309\u884c\u6216\u5217\u5206\u5272\u77e9\u9635\u7b49\uff0c\u6700\u7ec8\u5b9e\u73b0\u4e86\u4e00\u4e2a\u4e3b\u51fd\u6570\u6765\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u5206\u5272\u65b9\u5f0f\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u591a\u4e2a\u8fd0\u884c\u5b9e\u4f8b\uff0c\u9a8c\u8bc1\u4e86\u7b97\u6cd5\u7684\u6b63\u786e\u6027\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2692,81,427],"topic":[],"class_list":["post-39453","post","type-post","status-publish","format-standard","hentry","category-server","tag-leetcode","tag-python","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/39453.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb254\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u5173\u4e8e\u77e9\u9635\u5206\u5272\u7684\u7b97\u6cd5\u95ee\u9898\uff0c\u8981\u6c42\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6216\u5782\u76f4\u5206\u5272\u7ebf\u5c06\u77e9\u9635\u5206\u6210\u4e24\u90e8\u5206\uff0c\u4f7f\u5f97\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u76f8\u7b49\uff0c\u6216\u8005\u6700\u591a\u79fb\u9664\u4e00\u4e2a\u5355\u5143\u683c\u540e\u4f7f\u5b83\u4eec\u76f8\u7b49\uff0c\u5e76\u4e14\u4fdd\u6301\u8fde\u901a\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u63cf\u8ff0\u4e86\u95ee\u9898\u7684\u80cc\u666f\u3001\u793a\u4f8b\u3001\u5206\u6790\u601d\u8def\u4ee5\u53ca\u5b9e\u73b0\u65b9\u6cd5\u3002\u901a\u8fc7\u8bbe\u8ba1\u591a\u4e2a\u8f85\u52a9\u51fd\u6570\uff0c\u5982\u68c0\u67e5\u8fde\u901a\u6027\u3001\u8ba1\u7b97\u77e9\u9635\u548c\u3001\u6309\u884c\u6216\u5217\u5206\u5272\u77e9\u9635\u7b49\uff0c\u6700\u7ec8\u5b9e\u73b0\u4e86\u4e00\u4e2a\u4e3b\u51fd\u6570\u6765\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u5206\u5272\u65b9\u5f0f\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u591a\u4e2a\u8fd0\u884c\u5b9e\u4f8b\uff0c\u9a8c\u8bc1\u4e86\u7b97\u6cd5\u7684\u6b63\u786e\u6027\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/39453.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-23T10:13:43+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39453.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/39453.html\",\"name\":\"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-23T10:13:43+00:00\",\"dateModified\":\"2025-05-23T10:13:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/39453.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/39453.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39453.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/39453.html","og_locale":"zh_CN","og_type":"article","og_title":"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb254\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u5173\u4e8e\u77e9\u9635\u5206\u5272\u7684\u7b97\u6cd5\u95ee\u9898\uff0c\u8981\u6c42\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6216\u5782\u76f4\u5206\u5272\u7ebf\u5c06\u77e9\u9635\u5206\u6210\u4e24\u90e8\u5206\uff0c\u4f7f\u5f97\u4e24\u90e8\u5206\u7684\u5143\u7d20\u548c\u76f8\u7b49\uff0c\u6216\u8005\u6700\u591a\u79fb\u9664\u4e00\u4e2a\u5355\u5143\u683c\u540e\u4f7f\u5b83\u4eec\u76f8\u7b49\uff0c\u5e76\u4e14\u4fdd\u6301\u8fde\u901a\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u63cf\u8ff0\u4e86\u95ee\u9898\u7684\u80cc\u666f\u3001\u793a\u4f8b\u3001\u5206\u6790\u601d\u8def\u4ee5\u53ca\u5b9e\u73b0\u65b9\u6cd5\u3002\u901a\u8fc7\u8bbe\u8ba1\u591a\u4e2a\u8f85\u52a9\u51fd\u6570\uff0c\u5982\u68c0\u67e5\u8fde\u901a\u6027\u3001\u8ba1\u7b97\u77e9\u9635\u548c\u3001\u6309\u884c\u6216\u5217\u5206\u5272\u77e9\u9635\u7b49\uff0c\u6700\u7ec8\u5b9e\u73b0\u4e86\u4e00\u4e2a\u4e3b\u51fd\u6570\u6765\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u5206\u5272\u65b9\u5f0f\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u591a\u4e2a\u8fd0\u884c\u5b9e\u4f8b\uff0c\u9a8c\u8bc1\u4e86\u7b97\u6cd5\u7684\u6b63\u786e\u6027\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/39453.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-23T10:13:43+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/39453.html","url":"https:\/\/www.wsisp.com\/helps\/39453.html","name":"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-23T10:13:43+00:00","dateModified":"2025-05-23T10:13:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/39453.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/39453.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/39453.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u89e3\u51b3leetcode\u7b2c3548\u9898.\u7b49\u548c\u77e9\u9635\u5206\u5272II"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=39453"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39453\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=39453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=39453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=39453"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=39453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}