Why am i getting a runtime error??


  • 0
    J
    class Solution {
    

    public:
    bool containsNearbyDuplicate(vector<int>& nums, int k)
    {
    int i,j;
    vector<int> v;
    vector<int> t;
    for(i=0;i<nums.size();i++)
    {
    if(v[nums[i]]==1)
    {
    if(i-t[nums[i]]<=k)
    return 1;
    else
    continue;
    }
    else
    {
    v[nums[i]]=1;
    t[nums[i]]=i;
    }
    }
    return 0;
    }
    };


Log in to reply
 

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