다른분들 풀이 보니까 전체 합에서 빼시네..저건 생각 못했다..
class Solution {
public int missingNumber(int[] nums) {
Arrays.sort(nums);
int answer=-1;
for(int i=0;i<nums.length;i++){
if(nums[i]==i){
continue;
}else{
answer=i;
break;
}
}
if(answer==-1){
answer=nums.length;
}
return answer;
}
}
'문제풀이' 카테고리의 다른 글
Leetcode Number of 1 Bits JAVA (0) | 2021.01.04 |
---|---|
Leetcode Intersection of Two Arrays II JAVA (0) | 2020.12.28 |
Leetcode First Unique Character in a String JAVA (0) | 2020.12.25 |
Leetcode Pascal's Triangle II JAVA (0) | 2020.12.24 |
Leetcode Merge Two Sorted Lists (0) | 2020.12.23 |