Maximum Power DP

Getting WA
Link to code

You cant do any kind of sorting.
You have to take continous subarrays!

But i am sorting the dp array which contains answers , so the maximum value obtained at any position will be the ans.

Whats your logic??

 for(int i=1;i<n;i++){
        if(v[i]>0){
            if(dp[i-1]>0){
                dp[i]=dp[i-1]*v[i];
            }else{
                dp[i] = v[i];
            }
        }else{
            dp[i] = v[i];
        }
    }

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.