algorythms
Subsets / Combinations
LC #17Medium

Letter Combinations of a Phone Number

Subsets / Combinations
AmazonGoogleMetaBloomberg

Problem

Return all possible letter combinations that a phone number could represent.

stringbacktrackinghash-map

Constraints

  • 0 ≤ digits.length ≤ 4
  • digits[i] is in ['2','9']

Example

Inputdigits = "23"
Output["ad","ae","af","bd","be","bf","cd","ce","cf"]
Why

2→abc, 3→def. All combinations: 3×3 = 9

Hints — reveal one at a time