All problems

Problem 524

Valid Word Abbreviation

Easy · 10 pts · String, Two Pointers

Problem

An abbreviation replaces some non-overlapping, non-adjacent groups of letters of a word by their lengths. For example, substitution can become s10n or sub4u4 or 12. Numbers in an abbreviation never have leading zeros and are never 0. Given a word and a candidate abbreviation, decide whether the abbreviation is valid for that word. Walk through both with two pointers, skipping ahead in the word by each number you read.

Input

The first line contains the word W (lowercase letters). The second line contains the abbreviation B (lowercase letters and digits).

Output

Print YES if B is a valid abbreviation of W, otherwise NO.

Constraints

1 <= |W| <= 100; 1 <= |B| <= 100

Example input

internationalization
i12iz4n

Example output

YES

Explanation

For internationalization and i12iz4n: i matches, 12 skips nternational, i and z match, 4 skips atio, and n matches the last letter. The word is used up exactly, so the answer is YES.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Detect Capital Next: Student Attendance Record