Tap here to switch tabs
Problem
Submissions

Problem: Minimum Capacity Box

Minimum Capacity Box gives an array of box capacities and an item size. Return the index of the smallest box that fits, choosing the earliest index on ties, or negative one if none fit.

Statement

You are given an integer array capacity, where capacity[i] represents the capacity of the ithi^{ {th}} box, and an integer itemSize representing the size of an item.

A box can store the item if its capacity is greater than or equal to itemSize.

Return the index of the box with the minimum capacity that can store the item. If multiple boxes share this same minimum capacity, return the smallest index among them. If no box can store the item, return −1-1.

Constraints:

  • 1≤1 \leq capacity.length ≤100\leq 100

  • 1≤1 \leq capacity[i] ≤100\leq 100

  • 1≤1 \leq itemSize ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Capacity Box

Minimum Capacity Box gives an array of box capacities and an item size. Return the index of the smallest box that fits, choosing the earliest index on ties, or negative one if none fit.

Statement

You are given an integer array capacity, where capacity[i] represents the capacity of the ithi^{ {th}} box, and an integer itemSize representing the size of an item.

A box can store the item if its capacity is greater than or equal to itemSize.

Return the index of the box with the minimum capacity that can store the item. If multiple boxes share this same minimum capacity, return the smallest index among them. If no box can store the item, return −1-1.

Constraints:

  • 1≤1 \leq capacity.length ≤100\leq 100

  • 1≤1 \leq capacity[i] ≤100\leq 100

  • 1≤1 \leq itemSize ≤100\leq 100