3282. Reach End of Array With Max Score Medium

@problem@discussion
#Array#Greedy



1/**
2 * [3282] Reach End of Array With Max Score
3 *
4 * You are given an integer array nums of length n.
5 * Your goal is to start at index 0 and reach index n - 1. You can only jump to indices greater than your current index.
6 * The score for a jump from index i to index j is calculated as (j - i) * nums[i].
7 * Return the maximum possible total score by the time you reach the last index.
8 *  
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">nums = [1,3,1,5]</span>
12 * Output: 7
13 * Explanation:
14 * First, jump to index 1 and then jump to the last index. The final score is 1 * 1 + 2 * 3 = 7.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">nums = [4,3,1,3,2]</span>
19 * Output: 16
20 * Explanation:
21 * Jump directly to the last index. The final score is 4 * 4 = 16.
22 * </div>
23 *  
24 * Constraints:
25 * 
26 * 	1 <= nums.length <= 10^5
27 * 	1 <= nums[i] <= 10^5
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/reach-end-of-array-with-max-score/
33// discuss: https://leetcode.com/problems/reach-end-of-array-with-max-score/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn find_maximum_score(nums: Vec<i32>) -> i64 {
39        
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_3282() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.