This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimize Total Cost" covers key patterns like DP.
"With Amazon's new innovative OptiResource Kit users can effortlessly optimize the arrangement of their resource pools. This kit is designed to minimize the overall cost needed for efficient allocation. Formally, given an array cost of size m, utilizing the OptiResource Kit, users can perform operations on the array, in each operation, the user chooses two positions x and y such that the cost of the resource at position x (cost[x]) is divisible by the cost of the resource at position y (cost[y]). When this condition is satisfied, the cost of resource x can be updated to equal to the cost of resource y. This operation can be repeated as many times as possible, on different resources or positions. An integer x is divisible by another integer y if x can be divided by y exactly, with nothing left over, for example, 6 is divisible by 3, while 5 is not.  Find the minimum total cost after applying some (possibly zero) number of operations."
Join thousands of developers practicing for Amazon.