Tap here to switch tabs
Problem
Submissions

Problem: Sum of Good Numbers

med
30 min
Try to solve the Sum of Good Numbers problem.

Statement

Given an integer array nums and an integer k.

An element nums[i] is considered a good number if it satisfies the following conditions:

  • nums[i] > nums[i - k] whenever index i - k is within the bounds of the array.

  • nums[i] > nums[i + k] whenever index i + k is within the bounds of the array.

Return the sum of all good numbers in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤⌊\leq \lfloornums.length /2⌋/ 2\rfloor

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Good Numbers

med
30 min
Try to solve the Sum of Good Numbers problem.

Statement

Given an integer array nums and an integer k.

An element nums[i] is considered a good number if it satisfies the following conditions:

  • nums[i] > nums[i - k] whenever index i - k is within the bounds of the array.

  • nums[i] > nums[i + k] whenever index i + k is within the bounds of the array.

Return the sum of all good numbers in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤⌊\leq \lfloornums.length /2⌋/ 2\rfloor