Company: Amazon_17oct
Difficulty: medium
Problem Description Amazon operates a massive distributed system that handles millions of requests per second across services like Prime Video, Alexa, and AWS. Each request flows through a chain of servers represented as nodes in a pipeline. The initial state of each pipeline is stored in a database. A pipeline is represented as a string of characters where each character corresponds to a specific service node category (e.g., authentication, video streaming, storage). Due to a critical service outage caused by a bug, one specific category of service, represented by the character failed_service , begins to disrupt operations. Every second, all instances of the failed_service immediately terminate the service node that directly precedes them in the current pipeline in order to isolate the issue. Terminated services are simultaneously removed from the pipeline at the end of that second. Your task is to write a SQL query to determine the stabilization_time for each pipeline. The stabilizat