Solution by Shasank Shah