HackerEarth Different queries problem solution - TheCScience