Solution by Prajith P
