Find How Many Subarrays Match The Pattern

Asked at Meta · Coding Questions · Difficulty: Medium

5000 years agooo, in the magical land of Arithma, there existed an enchanted array called numbers, filled with special integers, and a mystical scroll called pattern that held the secret to finding certain relationships among the numbers. The pattern contained only 1, -1, or 0, each symbol representing a unique bond: 1 meant the current number must be greater than the previous one, -1 meant it must be smaller, and 0 indicated equality, like friends standing together unchanged. The council of Arithma sought to discover how many subarrays within numbers matched this magical pattern.

Loading the problem…