My java solution


  • 0
    C
    import java.util.*;
    
    public class Solution {
    public int singleNumber(int[] nums) {
        
        Hashtable<Integer,Integer> table = new Hashtable();
        
        for(int i=0;i<nums.length;i++)
        {
            if(table.containsKey(nums[i]) == false)
            {
                table.put(nums[i],i);
            }
            else
            {
                table.remove(nums[i]);
            }
        }
        Enumeration<Integer> keys = table.keys();
        return keys.nextElement();
    }
    

    }


Log in to reply
 

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