static int findMissingNumber(int start, int end, List<Integer> list) { // 创建一个完整的集合 List<Integer> all = new ArrayList<>(); for (int i = start; i <= end; i++) { all.add(i); } // 取两个集合之间的差集 all.removeAll(list); return all.get(0); }
Sign in to make a reply
三问麻雀