This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Can All Packages Be Delivered" covers key patterns like Other.
"### Problem You are managing Amazon's package delivery system, where each delivery truck can carry a certain amount of weight. The truck can only carry a specific amount of weight at a time, which decreases after every delivery. When a truck delivers a package, its weight-carrying capacity is reduced to half (rounded down to the nearest integer, i.e., floor division by 2). Each package has a weight, and the truck can only carry a package if the truck's capacity is equal to or greater than the package's weight. You are given t different shipment scenarios, where each scenario has: - An array truckCapacities of length n, representing the maximum weight each truck can carry. - An array packageWeights of length m, representing the weight of each package to be delivered. For each scenario, determine if delivering all packages using the available set of trucks is possible. If all packages can be delivered, return 1; otherwise, return 0. Return an array of boolean values representing the result for each shipment scenario. ### Input - t: Number of shipment scenarios - n: Length of truckCapacities - truckCapacities: Array of truck capacities - m: Length of packageWeights - packageWeights: Array of package weights ### Output - An array of boolean values representing the result for each shipment scenario"
Join thousands of developers practicing for Amazon.