Dear Student ,
when a soldier standing between two building fire a gun , the sound generated by the gun will be reflect back both the building.
now using the formula
given t1 = 2 sec , V= 340 m/s
Distance = speed * time
D1 = 340 * 2 = 680 m
now distance of the building = D1 / 2
= 680 /2 = 340 m
as the sound wave travel from the gun to building and then return back after reflection to the soldier.
Similarly Given t2 = 3 sec , V= 340 m/s
D2 = 340 *3 = 1020 m
Now distance of the building = D2 / 2
= 1020 / 2 = 510 m
Now distance between two building = 340 m + 510 m = 850 m
Regards