Python sliding window w/ explanation.
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing a sliding window, we can check for subarrays that have a maximum value that lies 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing a **sliding window**, we can check for subarrays that have a maximum value that lies within a range [left, right].\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe initialize **two pointers** that are used to represent the start and end of the window, respectively. The window slides through the \'nums\' list, and for each position, checks if the **maximum** value within the window falls within the range [left, right]. The length of the sliding window calculated allows us to determine how many subsequences there are. \n\nCases:\ni) The new element is within the range **[left, right]**. This means the whole subsequence preceding it is valid, so we set the length of the current sliding window. If the sequence so far is [a,b,c,d] (sliding window size is 4), and \'d\' lies in the range [left, right], there are 4 valid subsequences which are: [a, b, c, d], [b, c, d], [c, d] and [d]. This is why we add the **length of the sliding window directly to the count**.\n\nii) The new element is greater than **right**. This means the subsequence is **no longer valid**, so we reset the current sliding window length and move the left pointer to one after the end of the current window - as the current element will never be a part of a valid sliding window.\n\niii) The new element is **less than left**. This doesn\'t affect the validity of the subsequence - and so we don\'t change anything.\n\nAt the end of all these cases, we increment the count of subarrays by the current length of the sliding window.\n\nThanks @techie_sis for demonstrating that it\'s possible to do this using a sliding window! My intention with this solution is to hopefully go one step further into explaining how these sliding window approaches work.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe right pointer iterates through the length of the provided array once, so this is an O(n) operation. \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThere are 4 ints used, so the space complexity is O(1).\n# Code\n```\nclass Solution:\n    def numSubarrayBoundedMax(self, nums: List[int], left: int, right: int) -> int:\n        # Maximum of subarray lies in range [left, right]\n        left_ptr: int = 0\n        curr_arr_len: int = 0\n        count_of_subarr: int = 0\n        right_ptr: int = 0\n        for right_ptr in range(len(nums)):\n            # Traversing the provided array with the right pointer\n            if left <= nums[right_ptr] <= right:\n                curr_arr_len = right_ptr - left_ptr + 1\n            elif nums[right_ptr] > right:\n                # Maximum of subarray is past the upper bound\n                curr_arr_len = 0\n                left_ptr = right_ptr + 1 \n                # Set new sliding window\'s left to one after end.\n            count_of_subarr += curr_arr_len\n            # Add \n        return count_of_subarr\n```
['Sliding Window', 'Python3']