• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

Letter Combinations of a Phone Number

我的解法

第一次提交

介绍

虽然没有什么期待,但是貌似结果出乎意料的好,使用三重循环遍历的方式解决问题

思路

其实没啥好说的,就一层一层嵌套循环遍历呗

代码

/*

* @Author: fox

* @ date : 2022-05-02 17:04:48

* @ LastEditors: fox

* @ lastedittime : 2022-05-02 18:33:03

* @ description : https://lee tcode。com/problems/电话号码的字母组合/

*/

/**

* @描述:运行时: 91.73%内存使用率: 93.12%

* @param {string}位数

* @return {string[]}

*/

常量电话号码={

'0': [],

'1': [],

2': ['a ',' b ',' c'],

3': ['d ',' e ',' f'],

4': ['g ',' h ',' i'],

5': ['j ',' k ',' l'],

6': ['m ',' n ',' o'],

7': ['p ',' q ',' r ',' s'],

8': ['t ',' u ',' v'],

9': ['w ',' x ',' y ',' z']

}

常量字母组合=(数字,电话=电话号码)={

设RES=[];//存放结果数组

let store=[];//存放三次循环的结果

let temp=[];//存放一次循环的结果

如果(!数字| |数字。length===0)return[];//如果数字未定义或者长度为0, 直接返回[]

如果(数字。长度===1电话[数字[0]].length===0)return[];//如果数字长度=1,并且digtis[0]=1或0,直接返回[]

RES=phone[digits[0]];

对于(设I=1;我位数。长度;i ) {

temp=phone[digits];

store=[];

for(物的常数)

对于(温度的常量元素){

store.push(re元素);

}

}

res=商店

}

返回资源

}

让数字='23 '

console.log(字母组合(数字))

数字=' '

console.log(字母组合(数字))

数字='2 '

console.log(字母组合(数字))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now