Given an array of positive integers. Each integer in the input array represents the duration of a query that needs to be executed.
Write a function that is going to return the minimum amount of total waiting time for all the queries.
Waiting time - Amount of time a query waites till it starts executing.
Aim: Solve with Minimum Time Complexity and Space Complexity.- Only one query can be executed at a time.
- Queries can be executed in any order.
- Mutatation of the input array is allowed.
- Atleast one query is given.
# list of integers (waiting times)
coins = [3, 2, 1, 2, 6]
# Function must return 17 which is the total minimum waiting time