Subarray Counting
Problem Overview
- Count stretches of consecutive numbers that match a given comparison pattern.
- Input: integer array and pattern of -1/0/1; Output: number of subarrays of length pattern_length+1 that follow it.
- Applies to time-series trend matching and analytics.
- Must be reasonably efficient; exact constraints not given.
- From Databricks interviews; a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
