Amazon OA 2021 Questions

Question 1

We have to estimate the timeit will take for a worker to create the item ready to be ready for shipment. We are given number of parts and part sizes. The worker can only combine two parts at a time. The time required to put two parts together is equal to the sum of the parts sizes. The size of the newly constructed part is also equal to the sum of the parts's sizes. This process is repeated until all of the parts have been merged together. We have to write an algorithm to output minimum possible time to put the N parts together.

Input

4
8 4 6 12

Output

58
Comments (3)