<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之旅 廣告
                ![](https://box.kancloud.cn/edeb597f83c7fafbc05782105b391e70_617x515.png) ### 解題思路 ![](https://img.kancloud.cn/00/a8/00a85afa6161085eba2a9fc0723a61d3_996x511.png) * 設置對象映射 * 遍歷對應的字符串 * 第一次將字符串放到結果中 * 第二次及以后就雙遍歷生成新的字符串數組 ``` /** * @param {string} digits * @return {string[]} */ var letterCombinations = function(digits) { let result = [] if(digits.length == 0) return [] let numMap = { 2: 'abc', 3: 'def', 4: 'ghi', 5: 'jkl', 6: 'mno', 7: 'pqrs', 8: 'tuv', 9: 'wxyz' } for(let code of digits){ let word = numMap[code] if(result.length > 0){ let tmp = [] for(let char of word){ for(let old of result){ tmp.push(old+char) } } result = tmp }else{ result.push(...word) } } return result }; ``` ``` var letterCombinations = function(digits) { let len = digits.length; if(!len) return []; let dictionary = [[],[],['a','b','c'],['d','e','f'], ['g','h','i'],['j','k','l'],['m','n','o'], ['p','q','r','s'],['t','u','v'],['w','x','y','z']]; let res = [...dictionary[Number(digits[0])]]; console.log('res',res); for(let i = 1; i < len; i ++) { let temp = []; let arr = [...dictionary[Number(digits[i])]]; console.log('arr',arr) let resLen = res.length, arrLen = arr.length; for(let x = 0; x < resLen; x ++) { for(let y = 0; y < arrLen; y ++) { console.log('res[x]',res[x]) console.log('res[y]',res[y]) temp.push(res[x] + arr[y]); } } res = temp; } 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>

                              哎呀哎呀视频在线观看