Couldn't understand the given solution

could you plz provide an easier solution of the code