A surveillance system scans a video feed (represented as a string of event codes). Find the shortest continuous segment of feed that contains all the alarm codes specified in a given pattern. Return the shortest window containing all the alarm codes. Return 'NO' if not found.
Explanation: Step-by-step: The pattern A, B, C is not found in the given video feed ABCDE. The solution should return the shortest window containing all the alarm codes. The shortest window is 'ABC'.
Explanation: Step-by-step: The pattern A, C, E is not found in the given video feed ABCDE. The solution should return 'NO' because there is no window that contains all the alarm codes.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak