Easy C++ solution | Beats 100 %
IntuitionThe problem requires us to determine the maximum number of containers that can be loaded onto an n x n cargo deck without exceeding a given weight limi
# Intuition
The problem requires us to determine the maximum number of containers that can be loaded onto an n x n cargo deck without exceeding a given weight limit. Since each cell can hold exactly one container of weight w, we must balance the number of containers with the ship’s maximum weight capacity
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
- Calculate the total number of cells: Since the cargo deck is an n x n grid, it has cells = n * n total slots for containers.
- Compute the total weight if all cells are filled: If every cell holds a container, the total weight would be weight = cells * w.
- Check if the total weight exceeds maxWeight:
    - If weight ≤ maxWeight, then we can load all cells containers.
    - Otherwise, the number of containers must be limited to maxWeight / w, as each container weighs w

# Complexity
- Time complexity: 
    - The approach involves basic arithmetic calculations, which take constant time.
    - O(1)
 
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
    - We only use a few integer variables, requiring constant space.
    - O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maxContainers(int n, int w, int maxWeight) {
        int cells=n*n;
        int weight=cells*w;
        if(weight<maxWeight) return cells;
        else return maxWeight/w;
        
    }
};
```
['C++']