📦 Easy & Shorter Solution: Maximum Containers in an n × n Grid Under Weight Constraint ⚖️
IntuitionThe problem requires determining the maximum number of containers that can be placed in an ( n * n ) grid while ensuring that the total weight does not
# Intuition
The problem requires determining the maximum number of containers that can be placed in an \( n * n \) grid while ensuring that the total weight does not exceed `maxWeight`.  
- First, we calculate the total number of containers that can fit in the grid, which is \( n^2 \).  
- Then, we determine how many containers can be supported by the given weight capacity, which is `maxWeight // w`.  
- The final answer is the minimum of these two values.

# Approach
1. Compute the total number of containers that can fit in the grid:  
   - This is given by \( n^2 \), since it is an \( n * n \) grid.
2. Compute the maximum number of containers allowed by weight:  
   - Since each container has a weight `w`, the maximum number of containers that can be supported is `maxWeight // w`.
3. Return the minimum of these two values to ensure both space and weight constraints are satisfied.

# Complexity
- Time complexity:  
  - $$O(1)$$, since we only perform a few arithmetic operations.
  
- Space complexity:  
  - $$O(1)$$, as we use only a few integer variables and no additional data structures.


# Code
```python []
class Solution(object):
    def maxContainers(self, n, w, maxWeight):
        total_cells = n ** 2
        max_possible_containers = maxWeight // w
        return min(total_cells, max_possible_containers)

```
![upvote1.jpeg](https://assets.leetcode.com/users/images/8e937efe-de4c-45c6-87b1-6542b403a394_1743250853.5973294.jpeg)

['Python']