Git Product home page Git Product logo

algorithm's Introduction

algorithm's People

Contributors

jiindev avatar jjung45 avatar

Watchers

James Cloos avatar  avatar

Forkers

jiindev

algorithm's Issues

jiin / Letter Combinations of a Phone Number

/**

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.