Simple Java Solution


  • 1
    M
    public class Solution {
        public boolean containsDuplicate(int[] nums) {
            int i;
            Arrays.sort(nums);
            for(i=0;i<nums.length-1;i++)
            {
                if(nums[i]==nums[i+1])
                return true;
            }
            return false;
        }
    }

  • 0
    H

    Hi,

    Did you method get accepted? I didn't because it exceeds time limit.

    Thank you.


Log in to reply
 

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