상위 150개 인터뷰쉬움

전화번호의 문자 조합

'전화번호의 문자 조합' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

2부터 9까지의 숫자가 포함된 문자열이 주어지면 숫자가 나타낼 수 있는 가능한 모든 문자 조합을 반환합니다. 어떤 순서로든 답을 반환하세요.

전화 버튼과 마찬가지로 숫자를 문자로 매핑하는 방법은 다음과 같습니다. 1은 어떤 문자에도 매핑되지 않습니다.

2: abc, 3: def, 4: ghi, 5: jkl, 6: mno, 7: pqrs, 8: tuv, 9: wxyz

letterCombinations(digits: str) -> list 함수를 구현하세요.

제약
  • 0 <= digits.length <= 4
  • digits[i] is a digit in the range ['2', '9']

Example 1
Input
"23"
Output
["ad","ae","af","bd","be","bf","cd","ce","cf"]
Explanation

Digit 2 maps to 'abc' and digit 3 maps to 'def'. All combinations of one letter from each digit are generated.

Example 2
Input
""
Output
[]
Explanation

Empty input produces no combinations.

Example 3
Input
"2"
Output
["a","b","c"]
Explanation

Digit 2 maps to 'abc'.

Need a Hint?
세트 또는 힙과 같은 역추적 관련 데이터 구조를 사용하는 것이 좋습니다.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.