Signal Filter π¦
Sometimes it is necessary to filter a signal by frequency, e.g. to reduce noise outside of the expected frequency range. Filters can be stacked, allowing only the frequencies within the range allowed by all filters to get through. For example, three filters with ranges of [10, 17], [13, 15] and [13, 17] will only allow signals between 13 and 15 through. The only range that all filters overlap is [13, 15]. Given n signals' frequencies and a series of m filters that let through frequencies in the range x to y, inclusive, determine the number of signals that will get through the filters. There will be only one range where all the filters overlap.
Complete the function countSignals in the editor.
countSignals has the following parameter(s):
int frequencies[n]: the frequencies of the signals sent through the filtersint filterRanges[m][2]: the lower and upper frequency bounds for each filter
Returns
int: the number of signals that pass through all filters
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 β€ n β€ 1051 β€ m β€ 1051 <= frequencies[i] <= 1091 β€ frequencies[i], filterRanges[i][k] β€ 109