소스코드
List<Integer> AList = new ArrayList<Integer>();
for(int i= 0 ; i < A.length ; i ++){
AList.add(A[i]);
}
Collections.sort(AList);
int result = 1;
if(AList.get(0) != 1){
result = 0;
}
else{
if(AList.size() > 1){
for(int i = 1 ; i < AList.size() ; i ++){
if((AList.get(i) - AList.get(i-1)) != 1){
result = 0;
break;
}
}
}
}
System.out.println(result);
'공부-codility' 카테고리의 다른 글
[Lesson] 4. FrogRiverOne (0) | 2022.08.08 |
---|---|
[Lesson] 3. TapeEquilibrium (0) | 2022.08.04 |
[Lesson] 3. PermMissionElem (0) | 2022.08.04 |
[Lesson] 3. FrogJmp (0) | 2022.08.04 |
[Lesson] 2. Arrays - OddOccurrencesInArray (0) | 2022.08.04 |