Problem 3036 · Hard

Number of Subarrays That Match a Pattern II

Turn adjacent differences into up, equal and down signs, then find every occurrence of the pattern in those signs with KMP.

Open the interactive visualisation