排序+遍历
class Solution {
public:
bool isStraight(vector<int>& nums) {
sort(nums.begin(),nums.end());
int zero_num=0;
for(int n:nums){
if(!n)zero_num++;
else break;
}
if(nums[4]-nums[zero_num]>5)return 0;
for(int i=zero_num+1;i<5;i++){
if(nums[i]-nums[i-1]==1){
}else if(nums[i]-nums[i-1]==2&&zero_num>0){
zero_num--;
}else if(nums[i]-nums[i-1]==3&&zero_num>1){
zero_num=zero_num-2;
}else{
cout<<i<<" "<<nums[i]-nums[i-1]<<" "<<zero_num<<endl;
return 0;
}
}
return 1;
}
};