一、题目内容

image.png

二、题解

解法1:

思路

代码

  1. public class Solution {
  2. public int minNumberDisappeared (int[] nums) {
  3. // write code here
  4. if(nums == null || nums.length == 0){
  5. return 1;
  6. }
  7. int len = nums.length;
  8. Arrays.sort(nums);
  9. int i = 0;
  10. for(;i<len;i++){
  11. if(nums[i]>0){
  12. break;
  13. }
  14. }
  15. if(i == len){
  16. return 1;
  17. }
  18. int ans = 1;
  19. for(;i<len;i++){
  20. if(nums[i] == ans){
  21. ans++;
  22. continue;
  23. }else{
  24. return ans;
  25. }
  26. }
  27. return i == len? ans:1;
  28. }
  29. }