HackerEarth Find the Next! problem solution - TheCScience