HARDasked at 1 company

Maximum Total Beauty of the Gardens

A hard-tier problem at 30% community acceptance, tagged with Array, Two Pointers, Binary Search. Reported in interviews at Intuit and 0 others.

Founder's read

Maximum Total Beauty of the Gardens is a hard array problem that looks deceptively straightforward until you realize the greedy approach fails. You're given two arrays representing flower and tree costs, and you need to maximize beauty under a budget constraint. Intuit has asked this problem. The acceptance rate sits at 30%, which tells you that most candidates either brute-force and time out, or miss the critical insight about how to pair flowers and trees optimally. If this hits your live assessment and you blank on the pattern, StealthCoder solves it in seconds, invisible to the proctor.

Companies asking
1
Difficulty
HARD
Acceptance
30%

Companies that ask "Maximum Total Beauty of the Gardens"

If this hits your live OA

Maximum Total Beauty of the Gardens is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The trap here is thinking you can greedily pick the cheapest flowers and trees. You can't. The real solution requires sorting both arrays, then using a two-pointer or binary search strategy to enumerate all valid splits: for each flower budget threshold, find the best trees you can afford with remaining budget. Prefix sums let you compute the maximum tree beauty in a range without recomputing. Most candidates see 'maximize beauty' and jump to a single greedy pass. That fails because the optimal flower set doesn't always pair with the optimal tree set under budget. You need to iterate through flower choices systematically and track cumulative beauty. This is where StealthCoder becomes your hedge for the live OA: if you haven't drilled the enumeration plus prefix sum combo, the solution surfaces immediately.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Maximum Total Beauty of the Gardens recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Total Beauty of the Gardens interview FAQ

Why doesn't a simple greedy approach work?+

Picking cheapest flowers first doesn't guarantee the best pairing with trees. The optimal solution might use fewer, higher-beauty flowers to leave budget for premium trees. You must enumerate different flower selections and compute the best trees for each, which is why enumeration and prefix sums are key.

Is this problem still asked at Intuit?+

Yes. Intuit has this problem on record. At 30% acceptance, it's a serious vetting filter for candidates claiming strong array and optimization skills. Expect it in their technical screening or OA rounds.

What's the trick to staying efficient?+

Sort both arrays. Use prefix sums on one array to query range maximums in O(1). Then iterate the other array with a two-pointer or binary search to find valid budget splits. This avoids the naive O(n^2) nested loop that times out on large inputs.

How do two pointers and binary search both apply here?+

Two pointers works if you iterate flowers and shrink the tree range as budget tightens. Binary search works if you binary search for the largest tree you can afford after spending on flowers. Both lead to O(n log n) overall. Pick whichever feels more natural to code.

What happens if I miss the prefix sum optimization?+

You'll recompute the maximum tree beauty for every flower selection, hitting O(n^2) or worse. On large test cases, this times out. Prefix sums reduce the beauty lookup from O(n) to O(1), which is the difference between a solve and a TLE.

Want the actual problem statement? View "Maximum Total Beauty of the Gardens" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.