Count Faults
Problem Overview
- Task: Implement countFaults to count how many times a server is replaced after three consecutive 'error' logs for the same ID.
- Input: n servers and m log lines in '<server_id> success|error' format; Output: integer replacements count.
- Context: Prototype service to detect and swap faulty servers to improve application availability.
- Constraints: 1 <= n <= 200; 1 <= m <= about 2×10^4.
- From Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
