Hackerrank – Flowers

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Sort all prices descending.
The formula for calculating the flower i in prices:
$$total = \sum_{i=0}^{n-1}((i / k + 1) * price_{i})$$

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Ruby

Scala