In 40 sec, he covers the square. In 10 seconds he covers one side.
We want displacement after 140 seconds.
Let the sides of the square be A,B,C,D in the order of his walking. The in 120 seconds, he make 3 full rounds. In the remaining 20 seconds, he covers side A and side B.
He is at the opposite end of the diagonal at 140 sec.
Displacement is 10√2 = 14.14 meters from initial position