Practice Maximize Grid Happiness
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximize Grid Happiness
Problem Statement
Place up to introvertsCount introverts and extrovertsCount extroverts in separate cells of an m by n grid; leaving cells empty or people unplaced is allowed. An introvert contributes 120 minus 30 for each occupied side-adjacent neighbor. An extrovert contributes 40 plus 20 for each such neighbor. Compute each resident's contribution independently and maximize their total. Return that maximum happiness.
Source: Maximize Grid Happiness on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2
240
# Example 2
m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1
260
# Example 3
m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0
240
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize Grid Happiness.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.