Note - See the problem source section below for the original prompt π°π°
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. They knew that numbers was longer than pattern, and they weren't seeking the swiftest way, but rather one that required at most numbers.length * pattern.length steps, enough to uncover all matching subarrays and reveal the hidden tales within.
Example 1:
Input: numbers = [4, 1, 3, 4, 4, 5, 5 ,1], pattern = [1, 0, -1]
Output: 1
Explanation:Unfortunatelly, the explanation I found was not complete...So I will add it later when I find more reliable source. If you happen to know the complete explanation, you are more than welcome to tell me and I will add it here :) You are the best! π¦π¦
ππ


input:
output: