How does the intution come?

How as a coder should i start thinking to arrive at a solution as explained in the video