The test sample below is not correct:
[1,1,1,1,2,1]
since nums[i] will be an integer between 0 and 49,999
which results in my code getting RE?
class Solution {
public:
int findShortestSubArray(vector<int>& nums) {
int n = nums.size();
int a[50001];
memset(a, 0, sizeof(a));
for(int i = 0; i < n; i++)
a[nums[i]]++;
int max = 0;
for(int i = 0; i < n; i++)
if(max < a[i])
max = a[i];
int ans = n;
for(int i = 0; i < n; i++)
if(max == a[i])
{
int left,right;
for(int j = 0; j < n;j++)
if(nums[j] == i)
{
left =j;
break;
}
for(int j = n1; j >= 0; j)
if(nums[j] == i)
{
right =j;
break;
}
if(ans>rightleft+1)
ans = rightleft+1;
}
return ans;
}
};
Wrong input sample given in Weekly Contest 54 Q1?


@alpc113 said in Wrong input sample given in Weekly Contest 54 Q1?:
since nums[i] will be an integer between 0 and 49,999
which results in my code getting RE?why this round not have announcement in contest? i don't know why this round will be rated.