Skip to content

Practice Count Number of Texts

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2266
LeetCode Problem

Count Number of Texts

Problem Statement

The phone keys map 2 to abc, 3 to def, 4 to ghi, 5 to jkl, 6 to mno, 7 to pqrs, 8 to tuv and 9 to wxyz. A letter is entered by pressing its key as many times as its one-based position in that group. Given the concatenated pressedKeys without letter boundaries, count the possible original text messages modulo 10^9 + 7. Digits 0 and 1 are unused.

Source: Count Number of Texts on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
pressedKeys = "22233"
Output
8

# Example 2

Input
pressedKeys = "222222222222222222222222222222222222"
Output
82876089

Constraints

1 <= pressedKeys.length <= 10^5
pressedKeys only consists of digits from '2' - '9'.

Related LeetCode Problems

Practice more problems similar to Count Number of Texts.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.