FunctionRacerProblemsRace

Valid Word Abbreviation

EasyTwo pointersPython, JavaScript, TypeScript, Java, C++

An abbreviation replaces some runs of letters of a word by the length of the run. For example internationalization can be written i12iz4n. The numbers have no leading zeros, and a number may not be 0.

Return True if abbr is a valid abbreviation of word, otherwise False.

Example 1

word "internationalization"
abbr "i12iz4n"
returns true

The numbers 12 and 4 skip exactly the right letters.

Example 2

word "apple"
abbr "a2e"
returns false

Skipping 2 letters leaves le, not e.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Two pointers problems