Skip to content

Practice Maximum Containers on a Ship

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3492
LeetCode Problem

Maximum Containers on a Ship

Problem Statement

You are given a positive integer n representing an n x n cargo deck on a ship. Each cell on the deck can hold one container with a weight of exactly w. However, the total weight of all containers, if loaded onto the deck, must not exceed the ship's maximum weight capacity, maxWeight. Return the maximum number of containers that can be loaded onto the ship.

Source: Maximum Containers on a Ship on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2, w = 3, maxWeight = 15
Output
4

# Example 2

Input
n = 3, w = 5, maxWeight = 20
Output
4

Constraints

1 <= n <= 1000
1 <= w <= 1000
1 <= maxWeight <= 10^9

Related LeetCode Problems

Practice more problems similar to Maximum Containers on a Ship.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.