📦 Maximum Containers Calculation
Intuition🚀 IntuitionThe problem requires us to calculate the maximum number of containers that can be used while considering two constraints:Since we need the m
# Intuition
🚀 Intuition

The problem requires us to calculate the maximum number of containers that can be used while considering two constraints:

    1. The total number of available containers, which is n * n (assuming a square arrangement).

    2. The weight constraint, which limits the number of containers based on maxWeight / w (each container has weight w).

Since we need the minimum of these two constraints, the final result is:
min⁡(n×n,maxWeightw)
min(n×n,wmaxWeight​)

# Approach
💡 Approach

    1. Compute the total available containers:
    n×n
    n×n

    2. Compute the maximum containers allowed by weight:
    maxWeightw
    wmaxWeight​

    3. Take the minimum of both values.

    4. Use parseInt() to ensure the result is an integer (since containers must be whole numbers).
# Complexity
Time Complexity:

    O(1)O(1) – Only a few mathematical operations are performed.

Space Complexity:

    O(1)O(1) – Uses only a few variables.
# Code
```javascript []
/**
 * @param {number} n
 * @param {number} w
 * @param {number} maxWeight
 * @return {number}
 */
var maxContainers = function(n, w, maxWeight) {
    return parseInt(Math.min(n*n,maxWeight/w));
};
```


✅ Explanation with Example
Example 1

Input:

n = 3, w = 2, maxWeight = 10

Calculations:

    n2=32=9n2=32=9

    102=5210​=5

    Math.min(9, 5) = 5

Output:

5

Example 2

Input:

n = 4, w = 1, maxWeight = 20

Calculations:

    n2=42=16n2=42=16

    201=20120​=20

    Math.min(16, 20) = 16

Output:

16

🏆 Why This Solution is Efficient

✅ Only uses simple math operations – No loops needed.
✅ Runs in constant time O(1)O(1) – Fast execution.
✅ Handles all edge cases – Works for small and large values of n, w, and maxWeight.
🔥 Status: Accepted ✅
['JavaScript']