复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20public int[] missingTwo(int[] nums) { Arrays.sort(nums); int n=nums.length; int[] ans=new int[2]; int idx=0; int num=1; for(int i=0;i<n;num++){ if(nums[i]!=num){ ans[idx++]=num; }else i++; } if(idx==0){ ans[0]=num; ans[1]=num+1; } if(idx==1) ans[1]=num; return ans; }
最后
以上就是激昂导师最近收集整理的关于2022.9.26-----leetcode.面试.17.19的全部内容,更多相关2022内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复