Java solution  || Time Complexity : O(n)
Complexity
Time complexity: O(n)

Space complexity: O(1)
Code


# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int maxContainers(int n, int w, int maxWeight) {
        int count = 0;
        int wt = 0;
        while(wt < maxWeight && count < n*n){
            wt += w;
            if(wt <= maxWeight){
                count++;
            }
        }
        return count;
    }
}
```
['Java']