随笔 - 103,  文章 - 0,  评论 - 1,  阅读 - 16万
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   独醉笑清风  阅读(613)  评论(0编辑  收藏  举报
< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

点击右上角即可分享
微信分享提示