LeetCode 1788. Maximize the Beauty of the Garden
Prefix Sum
Input: flowers = [1,2,3,1,2]
Output: 8
Explanation: You can produce the valid garden [2,3,1,2] to have a total beauty of 2 + 3 + 1 + 2 = 8.Input: flowers = [100,1,1,-3,1]
Output: 3
Explanation: You can produce the valid garden [1,1,1] to have a total beauty of 1 + 1 + 1 = 3.Input: flowers = [-1,-2,0,-1]
Output: -2
Explanation: You can produce the valid garden [-1,-1] to have a total beauty of -1 + -1 = -2.Solution:
PreviousLeetCode 1787. Make the XOR of All Segments Equal to ZeroNextLeetCode 1790. Check if One String Swap Can Make Strings Equal
Last updated