int count;
void dfs(int* nums,int numsSize,int diff,int index,int pre,int nowcount){
if(index>numsSize || nowcount>3) return;
if(index==numsSize && nowcount<3) return;
if(nowcount==3){
count++;
return;
}
if( nowcount==0 || nums[index]==diff+pre ){
dfs(nums,numsSize,diff,index+1,nums[index],nowcount+1);
dfs(nums,numsSize,diff,index+1,pre,nowcount);
}else{
dfs(nums,numsSize,diff,index+1,pre,nowcount);
}
}
int arithmeticTriplets(int* nums, int numsSize, int diff) {
count=0;
dfs(nums,numsSize,diff,0,0,0);
return count;
}
标签:numsSize,index,nowcount,算术,三元组,int,2367 From: https://www.cnblogs.com/llllmz/p/18088982