Algorithm · Capital One · Medium
You are given two integer arrays, nums and pattern, both indexed from 0. Each entry of pattern is one of -1, 0, or 1, and describes how one element should compare to the element just before it. A contiguous subarray nums[i..i + m - 1] having length m is said to match a pattern whose length is m - 1 when every index j with $$0 \le j nums[i + j]; when pattern[j] == 0, the two neighbors must be equal: nums[i + j + 1] == nums[i + j]; when pattern[j] == -1, the next element must…