Company: IBM
Difficulty: medium
Faulty Server Detection and Replacement Implement a prototype service to automate the detection and replacement of faulty servers to improve the availability of an application. There are n servers with ids s 1 , s 2 , ..., s n , and an array of strings, logs , of size m . Log format is <server_id> <success/error> : the id of the server, and the status of the processed request. If a particular server id logs an error for three consecutive requests, it is considered faulty and is replaced with a new server with the same id. Given n and the array logs , find the number of times a faulty server was replaced. Input Format The first line contains an integer n , the number of servers. The second line contains an array of strings logs of size m . Output Format Return the number of times a server was replaced. Constraints 1 ≤ n ≤ 100 1 ≤ m ≤ 1000 Examples Input: 2 [\"s1 error\", \"s1 error\", \"s2 error\", \"s1 error\", \"s1 error\", \"s1 error\", \"s2 success\"] Output: 1 The serve