Count Faults
Implement a prototype service to automate the detection and replacement of faulty servers to improve the availabity of an application.
There are n servers with its s1, s2,...,sn, 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 perticular 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 athe array logs, find the number of times a faulty server was replace.
Complete the function countFaults in the editor π.
countFaults has the following parameter:
int n: the number of serversString logs[m]: the application logsReturns
int: the number of times servers were replaced
1Example 1

Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 2001 <= m <= 2 * 104 (The source image is too blurry. It looked like 104 to me. If you find it incorrect, please let me know! Many thanks in advance πππ§‘π)