Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays of Length Three With a Condition

Count Subarrays of Length Three With a Condition asks you to count contiguous groups of three in an integer array where the first and third values sum to half the middle value. Values may be negative.

Statement

Given an integer array nums, return the number of contiguous subarrays of length 33 such that the sum of the first and third elements is equal to half of the middle element.

Constraints:

  • 3≤3 \leq nums.length ≤100\leq 100

  • −100≤-100 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays of Length Three With a Condition

Count Subarrays of Length Three With a Condition asks you to count contiguous groups of three in an integer array where the first and third values sum to half the middle value. Values may be negative.

Statement

Given an integer array nums, return the number of contiguous subarrays of length 33 such that the sum of the first and third elements is equal to half of the middle element.

Constraints:

  • 3≤3 \leq nums.length ≤100\leq 100

  • −100≤-100 \leq nums[i] ≤100\leq 100