Company: Visa_21_feb
Difficulty: medium
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>", where 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. Your task is to determine the total number of server replacements that occur while processing all log entries. Example Suppose n = 2 and logs = ["s1 error", "s1 error", "s2 error", "s1 error", "s1 error", "s2 success"] Output: 1 Explanation: Server s1 logs first error: [error] Server s1 logs second error: [error, error] Server s2 logs first error: [error] Server s1 logs third error: [error, error, error] → s1 is replaced Server s1 (new) logs first error: [err