448. 找到所有数组中消失的数字
作者:互联网
暴力解法
class Solution {
public List<Integer> findDisappearedNumbers(int[] nums) {
List<Integer> list = new ArrayList<>();
int n = nums.length;
boolean[] b = new boolean[n + 1];
for(int i : nums){
b[i] = true;
}
for(int i = 1;i <= n;i++){
if(!b[i]) list.add(i);
}
return list;
}
}
标签:448,数字,nums,int,List,list,boolean,数组,new 来源: https://blog.csdn.net/weixin_45900005/article/details/122006401