题解 | #扑克牌顺子#
我的暴力解法,太痛苦了
import java.util.HashMap; import java.util.*; import java.lang.*; public class Solution { public boolean IsContinuous(int [] numbers) { int v1=0; int v5=15; int zero=0; int count=0; int max=0; int min=15; int compare=numbers[0]; //int temp[14]; Map<Integer,Integer> map=new HashMap<Integer,Integer>(); //map.putAll(0,0); // numbers.length for(int i=0;i<5;i++){ if(numbers[i]==0){ zero++; count++; continue; }else{ if(numbers[i]>max){ max=numbers[i]; } if(numbers[i]<min){ min=numbers[i]; } } if(numbers[i]<v5){ v5=numbers[i];//获得最小值 if(map.containsKey(numbers[i])){ return false; }else { map.put(numbers[i],1); } count++; continue; } if (numbers[i]>v1){ v1=numbers[i];//获得最大值 if(map.containsKey(numbers[i])){ return false; }else { map.put(numbers[i],1); } count++; continue; } } //v5=compare; if((max-min)>4){ return false; } return true; } }