• Skip to primary navigation
  • Skip to content
  • Skip to footer
Tech is interesting
  • Posts
  • Categories
  • Tags
  • About
    Chengze Li

    Chengze Li

    Code Once, Think Twice

    • GitHub
    • Instagram

    Algorithm: Leetcode Contest 414

    less than 1 minute read

    3282. Reach End of Array with Max Score

    Solution

    class Solution {
        public long findMaximumScore(List<Integer> nums) {
            long res = 0, curMax = 0;
    
            for(int i: nums) {
                res += curMax;
                curMax = Math.max(i, curMax);
            }
    
            return res;
        }
    }
    

    Retro

    when it comes to array problem, greedy is always a good direction…

    Tags: leetcode

    Categories: Algorithm

    Updated: September 7, 2024

    Previous Next

    You May Also Enjoy

    Algorithm: Leetcode Contest 418

    less than 1 minute read

    3309. Maximum Possible Number by Binary Concatenation

    Algorithm: Leetcode Contest 417

    less than 1 minute read

    3304. Find the K-th Character in String Game I

    Algorithm: Leetcode Contest 412

    1 minute read

    3265. Count Almost Equal Pairs I

    Algorithm: Leetcode Contest 411

    less than 1 minute read

    3259. Maximum Energy Boost From Two Drinks

    • GitHub
    • Instagram
    • Feed
    © 2024 Tech is interesting. Powered by Jekyll & Minimal Mistakes.