HackerEarth Timely Orders problem solution - TheCScience