Calculating Maximum Containers on a Ship Deck Using Weight and Capacity Constraints
IntuitionThe problem requires determining the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's maximum weight
# Intuition
The problem requires determining the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's maximum weight capacity. My first thought was to calculate the total number of cells on the deck and compare it with the maximum number of containers allowed by the weight constraint. The answer would be the smaller of the two values.

# Approach
1. Calculate Total Cells: Compute the total number of cells on the n×n deck, which is n^2.
2. Calculate Maximum Containers by Weight: Determine the maximum number of containers allowed by the weight constraint, which is 
⌊maxWeight/w⌋.
3. Return the Minimum: The result is the minimum of the total number of cells and the maximum number of containers allowed by weight.

# Complexity
- Time complexity: $$O(1)$$

- Space complexity: $$O(1)$$

# Code
```cpp []
class Solution {
public:
    int maxContainers(int n, int w, int maxWeight) {
        return min(n*n,maxWeight/w);
    }
};
```
['C++']