# Question on the judgement.

• ``````class Solution {
public:
int dfs(int start , int end ,int dp[50005] , vector <int >nums){
if(end <= start) return 0;
if(end - start +1 == 2 * (dp[end] - dp[start-1]))
return end - start + 1;
else if(end - start +1 > 2 * (dp[end] - dp[start - 1])){
if(nums[start] == nums[end]){
return max(dfs(start + 1, end , dp , nums) ,dfs(start , end -1 , dp ,nums));
}else if(nums[start] == 1){
return dfs(start + 1, end, dp , nums);
}else
return dfs(start , end - 1 , dp , nums);
}else{
if(nums[start] == nums[end]){
return max(dfs(start + 1, end , dp , nums) ,dfs(start , end -1 , dp ,nums));
}else if(nums[start] == 0){
return dfs(start + 1, end, dp , nums);
}else
return dfs(start , end - 1 , dp , nums);
}
}
int findMaxLength(vector<int>& nums) {
int dp[50005];
dp[0] = 0;
for(int  i = 0 ; i < nums.size() ; i ++){
dp[i + 1] = dp[i] + nums[i];
}

return dfs(1 , nums.size() , dp , nums);
}
};
``````

When I submitted my code, I got a wrong answer and this data
[0,0,1,0,0,0,1,1]

However, when I run custom this data on custom testcase , it returned the correct result, which is I expected.

Does anyone know how this happened?

• Thank you so much!

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