3034. Number of Subarrays That Match a Pattern I
You are given a 0-indexed integer array
numsof sizen, and a 0-indexed integer arraypatternof sizemconsisting of integers-1,0, and1.A subarray
nums[i..j]of sizem + 1is said to match thepatternif the following conditions hold for each elementpattern[k]:
nums[i + k + 1] > nums[i + k]ifpattern[k] == 1.nums[i + k + 1] == nums[i + k]ifpattern[k] == 0.nums[i + k + 1] < nums[i + k]ifpattern[k] == -1.Return the count of subarrays in
numsthat match thepattern.
1 | class Solution { |