Loading Company...
This is a verified interview question from Persistent-systems. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Cutting Rods" covers key patterns like DP.
"A construction company owner has surplus metal rods of arbitrary lengths. A contractor will buy rods of the same exact integer length (saleLength). Rods can be cut to increase the number of sellable rods, but each cut costs costPerCut. Any leftover rods not matching saleLength are discarded. The total profit is calculated as: totalProfit = totalUniformRods × saleLength × salePrice - totalCuts × costPerCut Find the saleLength that maximizes profit."
Join thousands of developers practicing for Persistent-systems.