Leetcode 3036. Number of Subarrays That Match a Pattern II
Count how many length-(m+1) subarrays of nums satisfy the given adjacent-comparison pattern (pattern[k] specifies whether nums[i+k+1] is >, =, or < nums[i+k]). Reduce to a sign array of adjacent comparisons and count occurrences of the pattern as a contiguous substring (e.g., with KMP) to get a linear-time solution.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.