Count Server Replacements
Updated
Problem statement
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>", wherestatusis 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 to0.
Your task is to determine the total number of server replacements that occur while processing all log entries.
Function
countServerReplacements(n: int, logs: String[]) → intExamples
Example 1
n = 2logs = ["s1 error", "s1 error", "s2 error", "s1 error", "s1 error", "s2 success"]return = 1More Wells Fargo Online Assessment questions
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
- Longest Subsequence That Is a SubstringOA · Seen Jul 2026
- Overloaded Game Account InventoriesOA · Seen Jul 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
- High Resource Usage CustomersOA · Seen Nov 2025
Similar questions at other companies
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Branch with the Most FilesCapital One · OACapital One interview questions
- Config Store with Priority OverridesMicrosoft · PHONE SCREENMicrosoft interview questions
- Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions
- ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Count Server ReplacementsAkuna Capital · OAAkuna Capital interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Feature Flag EvaluationCVS Health · PHONE SCREEN