FastPrepCan Every Package Fit in a Box
Problems/Can Every Package Fit in a Box

Can Every Package Fit in a Box

IMC Trading logoIMC Trading● EasyINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a real IMC OA report. FastPrep reconstructed the executable prompt from the source-backed core task: two arrays, similar to LC 1889, but only checking whether all packages can fit. Estimated match rate: 85-90% for the core task, 65-75% for exact original wording.

You are given two integer arrays:

  • packages, where packages[i] is the size of the i-th package.
  • boxes, where boxes[j] is the capacity of the j-th box.

Each package must be placed into a distinct box, and each box can contain at most one package. A package of size p can fit into a box of capacity b when p <= b.

Return true if it is possible to assign every package to a different box so that all packages fit. Otherwise, return false.

Function

canFitPackages(packages: int[], boxes: int[]) → boolean

Examples

Example 1

packages = [2, 3, 5]boxes = [3, 5, 6, 2]return = true

The packages of sizes 2, 3, and 5 can be assigned to boxes with capacities 2, 3, and 5.

Example 2

packages = [2, 3, 5]boxes = [5, 3]return = false

There are only two boxes but three packages, so at least one package cannot be assigned.

Constraints

  • 1 <= packages.length, boxes.length <= 2 * 10^5
  • 1 <= packages[i], boxes[j] <= 10^9

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Minimum Space Wasted From PackagingOA · Seen Sep 2025

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions
  • Get Maximum PairsAmazon · OA
  • Find Maximum GreatnessTwilio · OATwilio interview questions
  • Binge WatchingVanguard · OAVanguard interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
  • Find Minimum Possible SizeMathWorks · OAMathWorks interview questions

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)

IMC Trading interview experiences

  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public boolean canFitPackages(int[] packages, int[] boxes) {
      // write your code here
    }

}
Checking account…