Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jiin / Letter Combinations of a Phone Number #36

Open
jiindev opened this issue Feb 26, 2020 · 1 comment
Open

jiin / Letter Combinations of a Phone Number #36

jiindev opened this issue Feb 26, 2020 · 1 comment

Comments

@jiindev
Copy link
Collaborator

jiindev commented Feb 26, 2020

/**

  • @param {string} digits

  • @return {string[]}
    */
    const letterCombinations = (digits) => {
    let charNum = {
    '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']
    }
    let result = [];
    let digitsLength = digits.length;
    let firstNum = digits[0];
    let secondNum = digits[1];
    let plusLetter = [];

    let letters = '';
    // for(let i=0; i<digitsLength; i++){
    // letters += charNum[digits[0][0]];
    // letters += charNum[digits[1][0]];
    // letters += charNum[digits[2][0]];

// letters += charNum[digits[0][0]];
// letters += charNum[digits[1][1]];
// letters += charNum[digits[2][0]];

// letters += charNum[digits[0][0]];
// letters += charNum[digits[1][2]];
// letters += charNum[digits[2][0]];

// for(let j=0; j<charNum[i].length; j++){
// letters += charNum[i][j];
// }
// if(letters.length===3){
// result.push(letters);
// letters='';
// }
// }

charNum[firstNum].forEach((item, index)=>{
    letters = '';
    let firstLetter = item
    charNum[secondNum].forEach((item2, index2)=>{
        letters = (item+item2);
        result.push(letters);
    })
})
return result;

};

Letter Combinations of a Phone Number

케이스 한개는 통과했는데 나머지가 통과 안돼서 세이브 ㅠㅠ 내일 이어서 풀겄소

@jiindev jiindev changed the title 풀던거 세이브 jiin / Letter Combinations of a Phone Number Feb 26, 2020
@jiindev
Copy link
Collaborator Author

jiindev commented Mar 5, 2020

휴이건..어칸담? 성장하고 다시 데리러가겠어

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant