Algorithm · Goldman Sachs · Hard
A construction company has an inventory of metal rods with lengths given by the array lengths. A buyer is willing to purchase rods only if every accepted rod has exactly the same integer length, which we will call saleLength. The company can cut any rod zero or more times. Each cut costs costPerCut dollars. After cutting, any piece whose length is not saleLength is discarded and earns nothing. Each accepted rod sells for saleLength * salePrice dollars. For an original rod of…
Checking your access…