#3282

Reach End of Array With Max Score

medium · 33.5% accepted · 225 likes · top 11%

array · greedy

Description

You are given an integer array nums of length n.

Your goal is to start at index 0 and reach index n - 1. You can only jump to indices greater than your current index.

The score for a jump from index i to index j is calculated as (j - i) * nums[i].

Return the maximum possible total score by the time you reach the last index.

Solution