private static List<Integer> findShunZi(List<Integer> tmpCards){
List<Integer> list = new ArrayList<>();
List<Integer> copyList = new ArrayList<>();
List<Integer> newList;
newList = tmpCards;
Collections.sort(newList);
for (int i = 0; i < newList.size(); i++) {
if (i != newList.size() - 1){
if (mod(newList.get(i))== mod(newList.get(i+1)-1)){
list.add(newList.get(i));
} else {
copyList.add(newList.get(i));
}
}
}
newList.removeAll(copyList);
list.add(newList.get(list.size()));

return list;
}

传入list 返回list,mod是对16取余,因为是16进制,更换掉即可,最后返回的是能组成相邻排序的list
posted on 2019-09-06 15:57  独醉笑清风  阅读(592)  评论(0编辑  收藏  举报