Hackerearth: Little Jhool and psychic powers

code:

another solution of mine: