Reported March 2024
Airbnbsimulation

Configurable Retry Strategies

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

Airbnb reported this one in March 2024, and it looks too easy to be dangerous. Configurable Retry Strategies is a straight simulation: walk the outcomes array, apply a retry budget, add up the waits. Most people lose it in the details, not the algorithm. You've got three strategies, an off-by-one on retry counts, and a string format that has to match exactly. If the OA lands in your inbox this week, read the rules twice before you type. StealthCoder sits invisibly as a safety net on the live OA if you blank on the edge cases, but the logic here is small enough to own yourself.

The problem

Simulate a retry client whose ordered attempt outcomes are provided in outcomes. Each outcome is either FAILURE or SUCCESS:value.
The client selects one retry strategy:
ONCE permits at most one retry after the initial attempt.
FIXED permits at most maxRetries retries and waits baseDelay milliseconds before each retry.
EXPONENTIAL permits at most maxRetries retries. The wait before retry number k, where the first retry is k = 1, is baseDelay * 2^(k - 1) milliseconds.
Inspect outcomes from left to right, beginning with the initial attempt at elapsed time 0. Stop at the first success or when the selected retry budget is exhausted. The input always contains enough outcomes for every permitted attempt.
Return SUCCESS:value|attempts|elapsed after a success, or FAILED|attempts|elapsed when every permitted attempt fails. attempts includes the initial attempt, and elapsed is the sum of waits before executed retries.

Function
simulateRetries(outcomes: String[], strategy: String, maxRetries: int, baseDelay: long) → String

Examples
Example 1
outcomes = ["FAILURE","SUCCESS:ok"]
strategy = "ONCE"
maxRetries = 5
baseDelay = 10
return = "SUCCESS:ok|2|10"
The initial attempt fails. ONCE permits one retry after a 10-millisecond wait, and that retry succeeds.
Example 2
outcomes = ["FAILURE","FAILURE","SUCCESS:ready","FAILURE"]
strategy = "EXPONENTIAL"
maxRetries = 3
baseDelay = 5
return = "SUCCESS:ready|3|15"
The two executed retries wait 5 and 10 milliseconds. The third attempt succeeds after 15 total milliseconds.
Example 3
outcomes = ["FAILURE","FAILURE","SUCCESS:late","FAILURE"]
strategy = "ONCE"
maxRetries = 3
baseDelay = 7
return = "FAILED|2|7"
ONCE stops after the initial attempt and one retry, so the later success is never inspected.

Constraints
strategy is ONCE, FIXED, or EXPONENTIAL.
0 <= maxRetries <= 30.
1 <= baseDelay <= 10^6.
outcomes.length is at least the maximum number of attempts allowed by the selected strategy.
Every outcome is exactly FAILURE or begins with SUCCESS:.
Every elapsed-time result fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is simulation. Compute the allowed retries first: ONCE gives 1, FIXED and EXPONENTIAL give maxRetries. Note that ONCE ignores maxRetries entirely, and example 3 tests exactly that. Then loop attempts from 0 to allowed retries inclusive. Attempt 0 costs no wait. Before attempt k (k >= 1), add the wait: baseDelay for FIXED, baseDelay * 2^(k-1) for EXPONENTIAL, baseDelay for ONCE. Use a long and a shift like 1L << (k-1), because an int overflows with maxRetries up to 30. On SUCCESS: return value, attempts so far, elapsed. The pitfall that sinks a first attempt is counting waits for retries that never ran, or reading maxRetries under ONCE. Only add the wait when you actually execute the retry. If you freeze, StealthCoder can hand you the loop live, but it's about fifteen lines.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Configurable Retry Strategies 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Airbnb reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Configurable Retry Strategies FAQ

What's the trick in the Airbnb Configurable Retry Strategies problem?+

There's no clever algorithm. The trick is the retry budget. ONCE always allows one retry regardless of maxRetries, while FIXED and EXPONENTIAL allow maxRetries. Get that number right, then loop and accumulate waits only for retries you actually execute.

How hard is this OA question really?+

Easy on algorithms, moderate on carefulness. It's a single pass over outcomes with O(maxRetries) work. People miss it through overflow, wrong exponent (k-1, not k), or ignoring that ONCE caps retries at one. Test all three examples by hand.

Do I need to worry about integer overflow?+

Yes. baseDelay can reach 10^6 and the exponent can reach 29, so the multiplier alone is over 500 million before scaling. Use a 64-bit long and compute the power as 1L << (k-1). The problem guarantees the final result fits in signed 64-bit.

What exact output format does it want?+

On success return SUCCESS:value|attempts|elapsed, where value is whatever follows the SUCCESS: prefix. On exhaustion return FAILED|attempts|elapsed. Attempts counts the initial try. Elapsed only sums waits before retries that executed. Pipes, no spaces.

How do I prepare for this in 48 hours?+

Write the function once from scratch and run the three examples. Then add edge cases: maxRetries = 0 with FIXED, success on the first attempt, and EXPONENTIAL with maxRetries = 30. Practice parsing the SUCCESS: prefix with a substring call. That covers nearly everything this question can throw.

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