My thought process is explained in the image