FastPrepCount Server Replacements
Problems/Count Server Replacements

Count Server Replacements

Akuna Capital logoAkuna Capital● EasyINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported question.

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

  1. The first line contains the integer n.
  2. The next line contains the integer m, the size of logs.
  3. Each of the next m lines contains one string element of logs.

Function

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

Examples

Example 1

n = 2logs = ["s1 error", "s1 error", "s2 error", "s1 error", "s1 error", "s2 success"]return = 1
  1. Server s1 logs its first error: [error].
  2. Server s1 logs its second error: [error, error].
  3. Server s2 logs its first error: [error].
  4. Server s1 logs its third consecutive error: [error, error, error], so it is replaced.
  5. The new server s1 logs its first error: [error].
  6. 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

More Akuna Capital Online Assessment questions

  • Delivery Management SystemOA · Seen Nov 2026
  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Remaining Drone PowerOA · Seen Nov 2026
  • Rolling MetricsOA · Seen Oct 2026
  • Vowel Substring GameOA · Seen Sep 2026
  • Competitive ForagingOA · Seen Sep 2026
  • Binary CircuitOA · Seen Sep 2026
  • Items SortOA · Seen Sep 2026
  • Minimize Malware Spread by Removing a NodeOA · Seen Sep 2026
  • K Smallest SubstringOA · Seen Sep 2026

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Student and Course EnrollmentWells Fargo · OAWells Fargo interview questions
  • Network Endpoint or Cycle BoundaryOpenAI · OA · PHONE SCREENOpenAI interview questions
  • Assign Server Numbers by TypeOura · OA
  • Filter Transaction Logs and Calculate Reliability MetricsStripe · OAStripe interview questions
  • Calculate Net ProfitJP Morgan Chase · OAJP Morgan Chase interview questions
  • Get Total RequestsAmazon · OA

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int countFaults(int n, String[] logs) {
      // write your code here
    }
}
Checking account…