Beat 80% simple few lines Java


  • 0
            List<Integer> res = new ArrayList();
            for (int i = 0; i < nums.length; i++) {
                int idx = nums[i] > 0 ? nums[i] : -nums[i];
                if (nums[idx - 1] < 0) res.add(idx);
                else nums[idx - 1] = ~nums[idx - 1] + 1;
            }
            return res;
    

Log in to reply
 

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