Skip to content

3492. Maximum Containers on a Ship 👍

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  int maxContainers(int n, int w, int maxWeight) {
    return min(n * n, maxWeight / w);
  }
};
1
2
3
4
5
class Solution {
  public int maxContainers(int n, int w, int maxWeight) {
    return Math.min(n * n, maxWeight / w);
  }
}
1
2
3
class Solution:
  def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
    return min(n * n, maxWeight // w)