HackerEarth Descending Weights problem solution - TheCScience