Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Amazon ships several parcels each day to multiple locations. The dispatch centers have conveyor belts where the parcel boxes are placed. In one such
Amazon ships several parcels each day to multiple locations. The dispatch centers have conveyor belts where the parcel boxes are placed. In one such center, there are a total of n boxes numbered 0, 1,.., (n-1), where the capacity of the th box is denoted by capacity[i]. A box numbered x, can contain a box numbered y, if capacity[x] is divisible by capacityly] i.e. capacity[y] is a factor of capacity[x]. A triplet of boxes (a, b c) is said to be sustainable if Osa- b return -1. Langu Example There are n = 7 boxes, and their capacities are capacity [1,2,6, 4, 107, 109, 1024]. 1 X 16 26 1 2 6 107 109 1024 Boxes (0, 1, 2) 1 divides 2 2 divides 6 1 2 Boxes (0, 1, 3) Boxes (0, 3, 6) 1 divides 4 4 divides 1024 1024 1 divides 2 2 divides 4 35 2 36 Boxes (0, 1, 6) 1 divides 2 2 divides 1024 37 } 2 1024 38 39 fu. 34 22223333333333 27 28 29 30 31 Boxes (1, 3, 6) 2 divides 4 4 divides 1024 1024 Maximum middle box capacity =4 The possible triplets (a, b, c) are (0, 1, 2), (0, 1, 3), (0, 1, 6), (0, 3, 6), (1, 3, 6). Amongst these, possible middle box capacities are 2 and 4, the maximum of which is 4. Return 4. Function Description Complete the function findMiddle mCapacity in the editor @ Function Description Complete the function findMiddleMaximum Capacity in the editor below. findMiddleMaximum Capacity has the following parameter: int capacity[n]: the capacities of the boxes Returns int: the maximum middle box capacity among all possible sustainable triplets. If no such triplet exists, return -1. Constraints 1n 105 1 capacity[i] 105,0 i Solve this in Python
Step by Step Solution
★★★★★
3.41 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
The provided images describe a problem where there are n boxes each with different capacities A box can contain another box if the capacity of the con...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started