Very easy java solution, no more space need


  • -7
    A
    public class Solution {
        public int singleNumber(int[] nums) {
            Arrays.sort(nums);
            for(int i = 0; i + 3 < nums.length; i += 3){
                if(nums[i] != nums[i + 1]){
                    return nums[i];
                }
            }
            return nums[nums.length - 1];
        }
    }

  • 4
    D

    Time complexity is O(NlogN),it's not a good solution.


Log in to reply
 

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