Valid Word Abbreviation
Reported by candidates from Meta's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The "i12iz4n" example in this Meta OA, reported September 2026, looks cute until you realize "12" is one skip, not a 1 and a 2. That's the whole problem. It's Valid Word Abbreviation, a string walk with two pointers, and it's short enough that one wrong edge case sinks you. You get a lowercase word and an abbreviation where digit runs mean skip that many characters, and no number can start with 0. If you blank on the parsing during the live assessment, StealthCoder runs invisibly as a safety net and hands you the clean pointer loop.
The problem
Given a lowercase word and an abbreviation, determine whether the abbreviation represents the word. A positive decimal number skips that many consecutive characters. A number may not start with 0. Function validWordAbbreviation(word: String, abbreviation: String) → boolean Examples Example 1 word = "internationalization" abbreviation = "i12iz4n" return = true The numeric parts skip 12 and 4 characters, and every literal matches. Example 2 word = "apple" abbreviation = "a2e" return = false After skipping two characters, the abbreviation expects e where the word has l. Constraints 1 <= word.length, abbreviation.length <= 100 word contains lowercase English letters. abbreviation contains lowercase English letters and digits.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Use two pointers, i on the word and j on the abbreviation. If abbreviation[j] is a letter, it must equal word[i], then advance both. If it's a digit, check for a leading zero first. A '0' that starts a number means return false. Then read the full digit run into one integer, add it to i, and move j past the run. The pitfalls are real. Parsing digits one at a time turns "12" into 1 then 2. Forgetting the leading-zero rule fails hidden tests. Skipping past the word's end is also a failure. At the finish, require i == word.length and j == abbreviation.length, so a short abbreviation doesn't pass by accident. Time is O(n + m) with O(1) space. If the pointer bookkeeping slips under pressure, StealthCoder is the hedge during the live OA.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Valid Word Abbreviation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as valid word abbreviation. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Meta's OA.
Meta reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Valid Word Abbreviation FAQ
How hard is Valid Word Abbreviation really?+
It's an easy problem with sharp edges. The idea is a simple two-pointer scan, but leading zeros, multi-digit numbers, and overshooting the word length cause most failures. If you handle those three, you're done in about fifteen lines.
What's the trick to the Meta version?+
Parse the whole digit run as one number, not digit by digit. Reject any number that starts with '0'. Then add the number to the word pointer and compare literals as you go. Check both pointers land exactly at the end.
What edge cases should I test before submitting?+
Test a number that starts with 0 like "a01". Test a skip larger than the remaining word. Test an abbreviation that ends early, and one that is all digits equal to the word length. Also try the examples, "i12iz4n" and "a2e".
Do I need extra space or a regex?+
No. A single pass with two integer pointers is enough, so space is O(1). Regex makes the leading-zero and bounds checks harder to reason about. Keep it manual and it's easier to debug when a test fails.
How do I prepare for this in 48 hours?+
Write this one from scratch twice without looking. Then do a couple of other two-pointer string problems to get comfortable with index bookkeeping. Focus on the end condition, where both pointers must finish exactly together, since that's where most wrong answers come from.