This commit is contained in:
2025-03-25 23:00:10 +08:00
parent a89bec24e9
commit a09362480a
3 changed files with 49 additions and 0 deletions

15
src/3427.c Normal file
View File

@@ -0,0 +1,15 @@
//
// Created by xfj12 on 2025/3/25.
//
#include <solution/3427.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
int subarraySum(int *nums, int numsSize)
{
int sum = 0;
for (int i = 0; i < numsSize; i++)
for (int j = max(0, i - nums[i]); j <= i; j++)
sum += nums[j];
return sum;
}