added a code submitted in hackerearth