Seems my solution is not meaning of the problem,but it was accepted


  • 0
    R

    public class Solution {

    public int singleNumber(int[] A) {
        java.util.Hashtable<Integer,Integer> els = new java.util.Hashtable<Integer,Integer>();
        for ( int i = 0; i < A.length; i++ ) {
            Integer c = els.get(A[i]);
            if ( c == null ) {
                els.put(A[i],1);
            } else if ( c == 1 ) {
                els.put(A[i],2);
            } else {
                els.remove(A[i]);
            }
        }
        return els.keys().nextElement();
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.