EASYasked at 10 companies

Length of Last Word

A easy-tier problem at 56% community acceptance, tagged with String. Reported in interviews at Qualcomm and 9 others.

Founder's read

Length of Last Word is an easy string problem that hits your assessment from companies like Amazon, Microsoft, Meta, and Apple. It seems trivial on the surface, which is exactly why candidates blank on it under time pressure. The trick isn't algorithmic complexity; it's edge case handling. You're extracting the length of the final word in a string after stripping trailing spaces, which sounds simple until you actually code it live and realize your loop is off by one or your trim logic is wrong. StealthCoder solves it in seconds if you freeze on the implementation.

Companies asking
10
Difficulty
EASY
Acceptance
56%

Companies that ask "Length of Last Word"

If this hits your live OA

Length of Last Word 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 Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The gotcha here is that naive string splitting or index-based approaches fail on strings with multiple trailing spaces or no spaces at all. Most candidates iterate backward from the end, counting characters until they hit a space, but they often double-count or forget to handle the boundary where the last word begins. A solid approach starts from the end of the string, skips all whitespace, then counts non-whitespace characters until you hit a space or run out of string. The acceptance rate sits around 56 percent, which tells you a lot of people rush the implementation and miss edge cases. If you hit this problem live and your first attempt doesn't account for trailing spaces or a single-word string, StealthCoder surfaces a working solution before you waste cycles debugging.

Pattern tags

The honest play

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

Length of Last Word 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 Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Length of Last Word interview FAQ

Is this problem actually asked at FAANG or is it just a screening warm-up.+

It's reported by all ten top companies including Amazon, Microsoft, Meta, and Apple. It's frequently a warm-up to test coding speed and attention to detail. Don't underestimate it just because the difficulty is easy; execution matters.

What's the trap everyone falls into.+

Off-by-one errors when iterating backward, and forgetting that trailing spaces don't count. You also need to handle single-word strings and strings that are only spaces. Many candidates code the happy path and fail edge cases.

Does knowing string manipulation libraries help or hurt.+

It helps if you remember the exact trim and split syntax for your language. It hurts if you rely on them and forget the edge cases they handle. Manual iteration backward is often clearer and doesn't require library knowledge.

How does this relate to other string topics in assessments.+

It's foundational. String manipulation appears across easy and medium problems. Nailing edge case handling here translates directly to confidence on harder string and array problems at the same company.

How much time should I spend on this during an OA.+

If you know the pattern, under five minutes to code and test. If you're stuck on edge cases, more than ten means you're second-guessing yourself. Trust the backward-iteration approach and move on.

Want the actual problem statement? View "Length of Last Word" 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.