Company: Rubrik SE Intern_2nov
Difficulty: medium
Count Stable Signal Segments Problem Description An audio engineer develops a sophisticated algorithm to analyze digital audio signals for forensic purposes. The signal is captured as a stream of numerical amplitude samples. A key part of the analysis involves identifying "stable signal segments". A segment is a continuous portion of the signal stream. To determine if a segment is stable, a special "Integrity Checksum" is calculated. This checksum is generated by performing a bitwise XOR operation on the amplitude samples at the very start and end of the segment. A signal segment is considered stable if its Integrity Checksum is not an outlier. That is, the checksum's value must fall inclusively between the lowest and highest amplitude samples recorded within that very segment. Your task is to help the engineer by writing a program to count the total number of stable signal segments in a given audio stream. Formally, you are given a signal stream as a sequence of N non-negative integer