Reported September 2026
Akuna Capitalsimulation

Count Server Replacements

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

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

Akuna Capital reported this one in September 2026, and the input sizes tell you something right away: 200 servers and 20,000 logs means you never need anything fancier than one pass. Count Server Replacements is a pure simulation with a hash map of consecutive error counts. It looks like a wall of text, but the logic is four lines. If your OA lands on this, the only way to lose is a parsing slip or a reset bug. StealthCoder sits invisibly on your screen as a safety net in case you blank mid-assessment, but this problem is small enough that you probably won't need it.

The problem

You have n servers with IDs "s1", "s2",..., "sn". The system processes a sequence of log entries, where each entry is formatted as "<server_id> <status>", and status is either "success" or "error".
For each server, track its consecutive errors:
If a server records three "error" logs in a row, it is considered faulty and is replaced. The replacement server keeps the same ID.
After a replacement, that server's consecutive error count resets to 0.
A "success" log also resets that server's consecutive error count to 0.
Determine the total number of server replacements that occur while processing all log entries.
Custom testing format
The first line contains the integer n.
The next line contains the integer m, the size of logs.
Each of the next m lines contains one string element of logs.

Function
countFaults(n: int, logs: String[]) → int

Examples
Example 1
n = 2
logs = ["s1 error", "s1 error", "s2 error", "s1 error", "s1 error", "s2 success"]
return = 1
Server s1 logs its first error: [error].
Server s1 logs its second error: [error, error].
Server s2 logs its first error: [error].
Server s1 logs its third consecutive error: [error, error, error], so it is replaced.
The new server s1 logs its first error: [error].
Server s2 logs a success, so its consecutive-error record resets.
Only server s1 is replaced, and it is replaced once.

Constraints
1 <= n <= 200
1 <= logs.length <= 2 * 10^4

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that there is no trick. Keep a map from server ID to its current consecutive error count. For each log, split on the space. If the status is error, increment that server's count. If the count hits 3, add one to the answer and reset it to 0. If the status is success, reset the count to 0. That's O(m) time and O(n) space. Brute force would only appear if you rescanned history for each log, and the 2 * 10^4 limit punishes that less than you'd think, but there's no reason to do it. The common pitfall is forgetting to reset after a replacement, so four errors in a row counts as two replacements instead of one. Another is treating errors as total instead of consecutive. If you freeze on the parsing or the reset order live, StealthCoder is the hedge that hands you the clean loop so you can keep moving.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Count Server Replacements 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 by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Akuna Capital reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Server Replacements FAQ

How hard is Count Server Replacements really?+

Easy. It's a straight simulation with a counter per server. The statement is long, but the logic is increment on error, reset on success, replace at three. If you've written a hash map loop before, you can finish this in a few minutes.

What's the trick to this Akuna Capital problem?+

Track consecutive errors per server ID in a map. When a count reaches 3, bump the answer and reset that count to zero. A success also resets to zero. Counts are independent per server, so logs from other servers never touch each other's state.

Do I need a hash map or can I use an array?+

Either works. Server IDs look like s1 to sn, so you can parse the number after the s and index into an array of size n+1. A hash map keyed by the full string is simpler and less error-prone. With n up to 200, performance doesn't matter.

What edge cases should I test?+

Test four or more errors in a row, which should give one replacement at the third and a fresh count after. Test error, error, success, error, error, which gives zero. Test interleaved servers, and a single log. Those cover the reset bugs people actually hit.

How do I prepare for this in 48 hours?+

Write this one from scratch twice, focusing on parsing the log line and resetting the counter. Then do a couple of other per-key state simulation problems. This pattern is common in OAs, and speed on the boilerplate is what matters, not new algorithms.

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

OA at Akuna Capital?
Invisible during screen share
Get it