Let the observer be 'd' distance away from the thunderstorm and let light take 't' time to reach the observer
Since the speed of sound and light remains constant in a particular medium, we can use
Speed = Distance/Time
For light,
3 x 10^8 = d/t
t = d/(3 x 10^8) -1
For sound,
339 = d/(t + 30) -2
Putting value from 1 in 2.
d = 10^4 m(approx)