To calculate the work done by friction, you multiply the friction force times the total length of the path on the surface that the mass is moved. The magnitude of the friction force on a horizontal surface is the product of the normal force on the surface, $mg$, and the coefficient of kinetic friction, which is designated $K$ in the problem, or $F_{f}=Kmg$.
If we assume the surface upon which the mass moves is in the x-y plane, and the the z direction is the vertical displacement, h, then the length of the path for calculating the friction work would be the total distance covered by the mass on the x-y plane.
In the x-y plane a "horizontal" displacement could mean (1) a displacement along the x- axis, (2) a displacement along the y- axis or (3) a combination of both as long as it does not involve a vertical displacement. The problem statement, at least to me, is not clear exactly what the path in the x-y plane is. But based on the answer, the total distance the mass has moved on the on the x-y appears to be I, whatever path that represents.
UPDATE:
Based on the image you just added, the normal force exerted by the mass at any point along the path is $mg$cos θ where θ is the angle between the tangent to the path at any point and the horizontal. This means that only horizontal components (θ= 0) of the displacement along the path contribute to friction work. The vertical components (θ = 90) of the path do not contribute. The end result is that the friction work depends only on the horizontal displacement, $l$.
Hope this helps.