Maximum Containers That Can Be Filled
IntuitionThe problem requires determining the maximum number of containers that can be filled given:Total available space: The number of containers that can fit
# Intuition
The problem requires determining the maximum number of containers that can be filled given:

Total available space: The number of containers that can fit in a given area, which is n * n.

Weight constraint: Each container has a fixed weight w, and the total weight cannot exceed maxWeight.
### **Your Approach Explanation:**  
1. **Calculate Space Constraint** → The maximum number of containers that can fit is `n * n`.  
2. **Calculate Weight Constraint** → The maximum number of containers based on weight is `maxWeight / w`.  
3. **Return the Minimum** → The final result is `Math.min(n * n, maxWeight / w)`, ensuring we don’t exceed either the space or weight limits.  

### **Time Complexity:**  
- The solution performs only a few arithmetic operations and a `Math.min()` comparison, all of which run in **O(1) (constant time).**  

### **Space Complexity:**  
- No extra data structures are used, so the space complexity is **O(1) (constant space).**


![Screenshot 2025-02-11 233508.png](https://assets.leetcode.com/users/images/949e9905-3179-4a2c-958c-a370fe3ede6a_1742713690.3508477.png)


# Code
```java []
class Solution {
    public int maxContainers(int n, int w, int maxWeight) {
        return Math.min(n*n,maxWeight/w);
    }
}

```
['Java']