题解
扑克牌顺子
http://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4
import java.util.*;
public class Solution {
/**
* max increasing subsequence
* @param arr int整型一维数组 the array
* @return int整型arr
*/
public int MLS (int[] arr) {
// write code here
if(arr.length==0||arr==null)return 0;
Set <Integer>set=new HashSet<>();
for(int i:arr){set.add(i);}
Iterator iterator=set.iterator();
int a[]=new int[set.size()];
int k=0;
while(iterator.hasNext()){
a[k]=(int)iterator.next();
k++;
}
Arrays.sort(a);
int max=1;
int j=0;
for(int i=1;i<a.length;i++){
if(a[i-1]+1!=a[i]){
j=i;
}
max=Math.max(max,i-j+1);
}
return max;
}
}