<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## [46\. 全排列](https://leetcode-cn.com/problems/permutations/) >Medium #### 思路 先在紙上推演一下這道題的解法: ``` #1 確定 1 : #2 2 or 3 #3 3 or 2 #1 確定 2 : #2 1 or 3 #3 3 or 1 #1 確定 3 : #2 1 or 2 #3 2 or 1 ``` 暴力解法的for循環嵌套數量是根據數組長度來決定的,現在是不可行的。通過上面的演算過程,我們也能想到,應該使用遞歸在求解:先定下一個,打開后面的門,再定一個打開后面的門,打開后最后,然后在一扇一扇門回來。 **遞歸終止條件**我們使用一個數組在記錄,現在選到了第幾個數字,開到了哪一扇門,當這個數組長度等于我們的元素個數時結束,開到了最后一扇門。 以上,AC! #### 代碼 python3 ``` class Solution: def helper(self, nums, result, cur, i): cur.append(i) if len(cur) == len(nums): result.append(cur) for n in nums: if n not in cur: self.helper(nums,result,cur[::],n) def permute(self, nums: List[int]) -> List[List[int]]: result = [] for n in nums: self.helper(nums, result, [], n) return result ```
                  <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>

                              哎呀哎呀视频在线观看