Untitled

Anonymous
plain_text
01/19/2025 3:22 PM
380 B
12
Indexable
fn(int[] arr)
{
    prefixMax = 0;
    maxScore = 0;
    int score = 0;
    for(int j=0;j<n;j++)
    {
       score = prefixMax + arr[j] - j;
       maxScore = Math.max(maxScore,score);
       prefixMax = Math.max(prefixMax,arr[j] + j);      
    }
    return maxScore;
}
Editor is loading...
Leave a Comment