Skip to main content

Checkpoint: adjacency contract

Challenge on lesson: Checkpoint: one pass, adjacency

CHALLENGE
Difficulty: intermediate+25 XP

Implement int letterDigit(String s): count occurrences of a letter immediately followed by a digit. "a1b2" → 2, "a12" → 1 (the '1' after 'a' qualifies; the '2' after '1' does not), "1a" → 0, "" → 0. One pass, compare each character with its successor.

Back to lesson: Checkpoint: one pass, adjacency