Signal Filter
Learn this problemProblem statement
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.
Function
countSignals(frequencies: int[], filterRanges: int[][]) → int
Complete the function countSignals in the editor below.
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 filterReturns
int: the number of signals that pass through all filters
Examples
Example 1
frequencies = [8, 15, 14, 16, 21]filterRanges = [[10, 17], [13, 15], [13, 17]]return = 2Example 2
frequencies = [20, 5, 6, 7, 12]filterRanges = [[10, 20], [5, 15], [5, 30]]return = 1Constraints
1 ≤ n ≤ 10^51 ≤ frequencies[i] ≤ 10^91 ≤ m ≤ 10^51 ≤ filterRanges[j][k] ≤ 10^9
More JPMorgan Chase problems
- Bitwise XOR SubsequencesOA · Seen Jul 2026
- Array ChallengeOA · Seen Jun 2026
- Minimum Cores to Handle ProcessesOA · Seen Jun 2026
- About ShippingOA · Seen Jun 2026
- Count Dropped RequestsOA · Seen Jan 2026
- Generate Table of ContentsOA · Seen Jan 2026
- Calculate Net ProfitSeen Jun 2025
- Find Total WeightSeen Jun 2025