Match Subarray to Pattern

Problem Overview

  • Count how many contiguous subarrays match a given pattern of rises, falls, or equals exactly.
  • Input: a list of numbers and a pattern of relative comparisons; Output: the total count of matching subarrays.
  • The pattern length determines the subarray size; assume reasonable input sizes.
  • Applies to trend matching in time series or behavioral sequence analysis.
  • An Uber interviews coding interview problem often seen as an 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: