Description
Solutions
Match Subarray to Pattern

Note - Checkout the source image below for the original prompt :)

Imagine you're given a list of numbers and a special pattern that describes how these numbers should relate to each other in a sequence—whether they rise, fall, or stay the same. Your task is to find how many smaller sequences within the list match this pattern exactly. Even though you don't need to find the most efficient way, your solution should be good enough to handle a reasonable amount of work without slowing down too much.

Example 1:

Input:  numbers = [4, 1, 3, 4, 4, 5, 5, 1], pattern = [1, 0, -1]
Output: 1
Explanation:
Note - Checkout the source image below for the original explanation :)
Constraints:
    🍅🍅
Thumbnail 0
Thumbnail 1
Testcase

Result
Case 1

input:

output: