Reported July 2026
Airbnbcounting

Robot Final Direction

Reported by candidates from Airbnb's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Airbnb OA. Under 2s to a working solution.
Founder's read

The Airbnb OA reported in July 2026 has a warm-up problem called Robot Final Direction, and the data structure it hinges on is a single integer. No array, no map, no stack. A robot starts at 0, reads a string of L and R, and you report where it ended up relative to the start. If you're expecting a trap, the trap is overthinking it. This is a counting problem, and it's the kind of easy opener that still burns people who rush the return values. StealthCoder sits there as a safety net on the live OA if your head goes blank, but you probably won't need it here.

The problem

A robot starts at position 0 on a horizontal line and follows a string commands containing only L and R.
Each L moves the robot one step to the left.
Each R moves the robot one step to the right.
After every command has been executed in order, return:
"L" if the robot stops to the left of its starting position.
An empty string if the robot stops at its starting position.
"R" if the robot stops to the right of its starting position.
A solution with time complexity no worse than O(commands.length^2) fits within the execution time limit.

Function
robotDirection(commands: String) → String

Examples
Example 1
commands = "RLLRLL"
return = "L"
The first two commands and the next two commands each return the robot to its starting position. The final two L commands leave it two steps to the left, so the result is "L".
Example 2
commands = "LLRLLLRRRR"
return = ""
The string contains five L commands and five R commands, so the robot returns to its starting position and the result is an empty string.
Example 3
commands = "RRL"
return = "R"
Two right moves and one left move leave the robot one step to the right, so the result is "R".

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that order doesn't matter. You only care about the net displacement, so keep one integer. Add 1 for each R, subtract 1 for each L, and walk the string once. That's O(n) time and O(1) space, well inside the stated O(n^2) allowance. Then map the sign: negative returns "L", positive returns "R", zero returns an empty string. The common pitfall is the zero case. People return "0" or "N" or null instead of an empty string, and the examples show it must be empty. Another slip is simulating positions in a list, which works but wastes effort. Don't track the path, just the final count. Test with "RRL" (expect "R") and a balanced string (expect empty). If you blank on the return mapping mid-assessment, StealthCoder can show the three-branch return so you recover fast and move on.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Robot Final Direction 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as robot return to origin. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Airbnb's OA.

Airbnb reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Robot Final Direction FAQ

How hard is Robot Final Direction really?+

It's very easy. One pass, one counter, three possible return values. The difficulty is only in being careful with the output format, especially returning an empty string for the balanced case instead of something like "0".

What's the trick to solving it?+

Order of moves doesn't matter, only the net total. Add one for R, subtract one for L, and check the sign at the end. Positive means "R", negative means "L", zero means an empty string.

What time complexity does Airbnb expect here?+

The problem says O(commands.length^2) is acceptable, but a single pass is O(n) and is the natural answer. Don't bother with anything fancier. Linear time and constant space is the clean solution to submit.

What edge cases should I test?+

Test an empty-looking balanced string like "LR", a string of all L, a string of all R, and a single character. The balanced case matters most because it must return an empty string, not a character or a number.

How do I prepare for this in 48 hours?+

Don't spend long on this one. Write the counter solution once from memory, then spend your time on harder array, hash-table, and string problems. Easy openers like this are usually followed by tougher questions in the same assessment.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Airbnb.

OA at Airbnb?
Invisible during screen share
Get it