EASYasked at 1 company

Number of Valid Words in a Sentence

A easy-tier problem at 30% community acceptance, tagged with String. Reported in interviews at Cisco and 0 others.

Founder's read

You're grinding through an Easy string problem and the acceptance rate is below 30%. That's not a difficulty ranking issue, it's a validation issue. Number of Valid Words in a Sentence asks you to count words that meet specific rules, and candidates keep getting tripped up on the edge cases. Cisco has asked this one. The pattern is straightforward string parsing, but the devil is in what makes a word valid. If you blank on the exact rules during the assessment, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
30%

Companies that ask "Number of Valid Words in a Sentence"

If this hits your live OA

Number of Valid Words in a Sentence is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The actual task is simple: iterate through the sentence and count words that contain only letters and hyphens, with hyphens not at the start or end of the word. The gotcha is that most solutions either miss the hyphen positioning rules or don't handle splitting correctly. Many candidates try regex and overcomplicate it. Others split naively and don't validate each token properly. The pattern is straightforward once you see it, but if you haven't drilled it before your live assessment and you panic, that's where StealthCoder becomes your hedge. You define what a valid word is, validate each token, count the matches. No trick, just precision.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of Valid Words in a Sentence recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Valid Words in a Sentence interview FAQ

Why is the acceptance rate so low for an Easy problem?+

Because the validation rules are strict and candidates miss edge cases with hyphen placement. It's a string parsing problem that looks trivial but punishes sloppy splitting. The low acceptance reflects real-world interview rigor, not problem difficulty.

What's the most common mistake?+

Not validating hyphen position correctly. Candidates often count words with leading or trailing hyphens as valid, or they assume any hyphen makes a character invalid. The rule is narrow: hyphens are allowed between letters only.

How is this different from other string problems?+

It's not about substring matching or pattern search. It's about defining and enforcing a strict validation rule across tokens. You're building a filter, not a searcher. Each word passes or fails a specific test.

Will Cisco ask this again?+

Cisco has asked it once in available reports. It's a reasonable screening problem for role clarity, so re-asks are possible. Easy string parsing problems cycle through company interview rotations.

Should I memorize the exact rules before my OA?+

Yes. Read the problem statement carefully on the day and write down exactly what makes a word valid before coding. That clarity step prevents the mistakes that tank the acceptance rate. If you forget mid-assessment, StealthCoder has your back.

Want the actual problem statement? View "Number of Valid Words in a Sentence" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.