Pattern Matching
Medium · Online assessment (OA) · Full-time
Given an array and a pattern of -1, 0, 1 values, count subarrays that follow the pattern where -1 means decreasing, 0 means equal, 1 means increasing between consecutive elements. I converted the original array into a difference pattern first, then did a sliding window comparison. Straightforward once you reframe it as pattern matching on the difference array.
