Contains Duplicate in C runtime Error


  • 0
    A

    bool containsDuplicate(int* nums, int numsSize) {
    int arr[2147483647]={0};
    int i=0;
    if(nums[0]==NULL)
    return false;
    while(i<numsSize){
    if(arr[nums[i]]==0){
    arr[nums[i]]++;
    i++;
    }
    else
    return true;
    }
    return false;
    }


  • 0
    T

    2147483647 is too big for an array,
    my own hash array[999999] pass the test cases.
    999999 is enough.


  • 0
    P

    example[-1,--1],wrong output


Log in to reply
 

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