LeetCode 448 --- Find All Numbers Disappeared in an Array
タイトルリンク:LeetCode 448—Find All Numbers Disappeared in an Array
ACコード:
ACコード:
public class Problem448 {
public static void main(String[] args) {
int [] a={4,3,2,7,8,2,3,1};
// TODO Auto-generated method stub
findDisappearedNumbers(a);
}
public static List<Integer> findDisappearedNumbers(int[] nums) {
List<Integer> list =new ArrayList<Integer>();
for(int i=1;i<=nums.length;i++)
list.add(i);
for(int i=0;i<nums.length;i++)
list.remove(new Integer(nums[i]));
return list;
}
}