You are given an integer array nums.
Your task is to count how many continuous subarrays of length 3 satisfy the following condition:
For a subarray [a, b, c], the sum of the first and third elements must be exactly half of the middle element, i.e.:
Return the total count of such valid subarrays.
Input: nums = [2, 8, 2, 4]
Output: 1
Explanation:
The subarray [2, 8, 2] is valid because 2 + 2 = 4 which equals 8/2.
Input: nums = [3, 6, 3, 6, 3]
Output: 0
Explanation:
Two valid subarrays are [3, 6, 3] appearing twice.
Accepted:
Submission: