HackerEarth Puzzled Grid problem solution - TheCScience