<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## [面試題29. 順時針打印矩陣](https://leetcode-cn.com/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/) >Easy #### 思路 * 按著題目理解的方式進行遍歷 * 一圈分成4個步驟,代碼使用 `%4` 來區分步驟 * 一圈結束后,要向內圈縮進一格 * 遍歷次數為m * n #### 代碼 python3 ``` class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: if len(matrix) == 0: return [] r = [] m = len(matrix) n = len(matrix[0]) count = 0 i = 0 j = 0 for k in range(m * n): #print((i,j)) r.append(matrix[i][j]) if count % 4 == 0: if j < (n - 1 - int(count / 4)): j +=1 else: i+=1 count += 1 elif count % 4 == 1: if i < (m - 1 - int(count / 4)): i +=1 else: j-=1 count +=1 elif count % 4 == 2: if j > int(count / 4): j-=1 else: i-=1 count +=1 else: if i> int(count/4) + 1: i-=1 else: j+=1 count +=1 return r ```
                  <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>

                              哎呀哎呀视频在线观看