class Solution {
public int[] resultsArray(int[] nums, int k) {
int le=nums.length;
int[] res=new int[le-k+1];
if(le<k){
return res;
}
int count=0,x=0;//x计算数组是否递增
for(int i=0;i<le-k+1;i++){
x=0;
for(int j=i+1;j<i+k;j++){
if(nums[j]-nums[j-1]!=1){
res[count]=-1;
x=-1;
count++;
break;
}
}
if(x==0){
res[count]=nums[i+k-1];
count++;
}
}
return res;
}
}
class Solution(object):
def resultsArray(self, nums, k):
le=len(nums)
res=[]
if le<k:
return res
x=0#x计算数组是否递增
for i in range(le-k+1):
x=0
for j in range(i+1,i+k):
if nums[j]-nums[j-1]!=1:
res.append(-1)
x=-1
break
if x==0:
res.append(nums[i+k-1])
return res