题目
https://www.nowcoder.com/practice/8cc4f31432724b1f88201f7b721aa391?tpId=190&&tqId=35388&rp=1&ru=/ta/job-code-high-rd&qru=/ta/job-code-high-rd/question-ranking
import java.util.*;
public class Solution {
/**
* return the min number
* @param arr int整型一维数组 the array
* @return int整型
*/
public int minNumberdisappered (int[] arr) {
// write code here
int mix = 1;
Arrays.sort(arr);
List<Integer> list = new ArrayList<>();
for(int i = 0 ; i < arr.length ; i++){
list.add(arr[i]);
}
for(int i=1 ;; i++){
if(!list.contains(i)){
mix = i;
break;
}
}
return mix;
}
}
全部评论
(0) 回帖