public static int singleNumberWithExtraMemory(int[] A) {

    	Set<Integer> set = new HashSet<Integer>();
    	
    	for (int i = 0; i < A.length; i++) {
    		
			if(!set.contains(A[i])) {
				set.add(A[i]);
			} else {
				set.remove(A[i]);
			}
		}
    	
    	int result = 0;
    	
    	if(set.size() == 1) {
	    	for (Integer integer : set) {
				result = integer;
			}
    	} else {
    		System.out.println("error");
    	}
    	return result;
    }