Skip to content

Practice Maximum Total Beauty of the Gardens

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2234
LeetCode Problem

Maximum Total Beauty of the Gardens

Problem Statement

flowers[i] is the existing count in garden i. Add at most newFlowers flowers without removing any. A garden is complete when its count is at least target. Beauty equals completeCount * full plus the smallest incomplete-garden count * partial; the latter term is 0 if none are incomplete. Return the greatest attainable beauty.

Source: Maximum Total Beauty of the Gardens on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
flowers = [1,3,1,1], newFlowers = 7, target = 6, full = 12, partial = 1
Output
14

# Example 2

Input
flowers = [2,4,5,3], newFlowers = 10, target = 5, full = 2, partial = 6
Output
30

Constraints

1 <= flowers.length <= 10^5
1 <= flowers[i], target <= 10^5
1 <= newFlowers <= 10^10
1 <= full, partial <= 10^5

Related LeetCode Problems

Practice more problems similar to Maximum Total Beauty of the Gardens.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.