Web appOpen in Telegram

PostQuestion: Maximum Sum Score of an Array

18 December 2024
<
< Ace Coding /> 🚀
Question: Maximum Sum Score of an Array You are given a 0-indexed integer array nums of length n. The sum score of nums at an index i (where 0 <= i < n) is defined as the maximum of: • The sum of the first i + 1 elements of nums. • The sum of the last n - i elements of nums. Your task is to return the maximum sum score of nums at any index. ▎Examples: 1. Input: nums = [4, 3, -2, 5] Output: 10 Explanation: • At index 0: max(4, 4 + 3 - 2 + 5) = max(4, 10) = 10. • At index 1: max(4 + 3, 3 - 2 + 5) = max(7, 6) = 7. • At index 2: max(4 + 3 - 2, -2 + 5) = max(5, 3) = 5. • At index 3: max(4 + 3 - 2 + 5, 5) = max(10, 5) = 10. • The maximum sum score of nums is 10. 2. Input: nums = [-3, -5] Output: -3 Explanation: • At index 0: max(-3, -3 - 5) = max(-3, -8) = -3. • At index 1: max(-3 - 5, -5) = max(-8, -5) = -5. • The maximum sum score of nums is -3. ▎Challenge: Write a function maximumSumScore(nums) that takes an integer array as input and returns the maximum sum score.
3 · 246 ·

Nearby in the feed

<< Ace Coding /> 🚀Substrings that begin and end with the same letter You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substri<< Ace Coding /> 🚀question from today interview question
this message
<< Ace Coding /> 🚀Photo<< Ace Coding /> 🚀https://leetcode.ca/2022-04-21-2219-Maximum-Sum-Score-of-Array/
<< Ace Coding /> 🚀< Ace Coding /> 🚀@AceCoding · channel · Tech
334subscribers345posts in the index
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog · Search · How we count