상세 컨텐츠

본문 제목

[Codiliy]OddOccurrencesInArray

Development/알고리즘

by J-Developer 2020. 6. 27. 19:15

본문

반응형

[문제]

 

[답안작성]

class Solution {
    public int solution(int[] A) {
        
        Set<Integer> tempSet = new HashSet<>();
		
		for( int a : A ) {
			
			if( tempSet.contains( a ) ) {
				tempSet.remove(a);
			}
			else {
				tempSet.add(a);
			}
			
		}
		
		return tempSet.iterator().next();
        
    }
}
반응형

'Development > 알고리즘' 카테고리의 다른 글

[Codility] TapeEquilibrium  (0) 2020.06.28
[Codility]PermMissingElem  (0) 2020.06.28
[Codility]FrogJmp  (0) 2020.06.27
[Codility]CyclicRotation  (0) 2020.06.27
[Codility]BinaryGap  (0) 2020.06.27

관련글 더보기

댓글 영역