Company: Visa_3Dec
Difficulty: medium
Count Sawtooth Subarrays Problem Description A sawtooth sequence is a sequence of numbers that alternate between even and odd. In other words, each element is of different parity than both of its neighboring elements. For example: [0, 1, 10, 7, 2] is a sawtooth sequence. (even, odd, even, odd, even) [9, 4, 3, 14] is a sawtooth sequence. (odd, even, odd, even) [2, 3, 5, 8, 7, 1] is not a sawtooth sequence because 3 and 5 are both odd. [7, 8, 2, 13] is not a sawtooth sequence because 8 and 2 are both even. Given an array of integers arr , your task is to count the number of contiguous subarrays that represent a sawtooth sequence. Note that any subarray of length 1 is considered a sawtooth sequence. Examples Example 1: Input: arr = [1, 3, 5, 7, 9] Output: 5 Explanation: Since all the elements are odd, it won't be possible to form any sawtooth subarrays of length 2 or more. There are 5 possible subarrays containing one element: [1], [3], [5], [7], [9]. Example 2: Input: arr = [1, 2, 1, 2,