소스코드 

Map<Integer, Boolean> AMap = new HashMap<>();
for (int i = 0; i < A.length; i++) {
	AMap.put(i+1, false);
}
AMap.put(AMap.size()+1, false);

for(int i = 0 ; i < A.length; i ++){
	AMap.put(A[i], true);
}

int result = 1;
Iterator<Integer> keys = AMap.keySet().iterator();
while( keys.hasNext() ){
	Integer key = keys.next();
	if(AMap.get(key) == false) {
		result = key;
		break;
	}
}
return result;

'공부-codility' 카테고리의 다른 글

[Lesson] 4. FrogRiverOne  (0) 2022.08.08
[Lesson] 3. TapeEquilibrium  (0) 2022.08.04
[Lesson] 3. FrogJmp  (0) 2022.08.04
[Lesson] 2. Arrays - OddOccurrencesInArray  (0) 2022.08.04
[Lesson] 2. Arrays - CyclicRotation  (0) 2022.08.04

+ Recent posts