<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                給定一個僅包含0和1的二維二進制矩陣,找出只包含1的最大矩形,并返回其面積。 **示例:** ~~~ 輸入: [ [ “1”, “0”, “1”, “0”, “0”], [“1”,“0”,“ 1 ”,“ 1 ”,“ 1 ”], [“1”,“1”,“ 1 ”,“ 1 ”,“ 1 ”], [ “1”, “0”, “0”, “1”, “0”] ] 輸出: 6 ~~~ 將二維數組轉化為一維數組: 用 dp[i] 表示從當前位置開始,該列向上的最多連續的 '1' 的個數。 對于每一行,使用動態規劃求出該行的 dp,再求解該行的 maxArea 并更新結果。 ``` /** * @param {character[][]} matrix * @return {number} */ const maxArea = (heights) => { const stack = []; let ans = 0; heights.unshift(0); heights.push(0); for (let i = 0; i < heights.length; ++i) { while (stack.length && heights[stack[stack.length-1]] > heights[i]) { const currentHeight = stack.pop(); const right = i - 1, left = stack[stack.length-1] + 1; ans = Math.max(ans, (right-left+1)*heights[currentHeight]) } stack.push(i); } return ans; } var maximalRectangle = function(matrix) { let res = 0; if (!matrix.length) return res; const dp = []; for (let i = 0; i < matrix[0].length; ++i) { dp.push(0); } for (let i = 0; i < matrix.length; ++i) { for (let j = 0; j < matrix[0].length; ++j) { dp[j] = matrix[i][j] === '1' ? dp[j] + 1 : 0; } res = Math.max(res, maxArea(dp.slice())); } return res; }; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看