First of all we need common UNIT for values to do the calculations correctly.
So, 1 hour = 60 mins.
8 workers -> 4320 bricks -> 60 mins
? workers -> 4320 bricks -> 40 mins
As you can see, here in both cases, the no. of bricks remains same. So we just need to consider the number of workers and the time taken.
60 mins -> 8 workers
So, 1 min -> 8 * 60 = 480 workers
We have 40 mins.
So, 40 mins -> 480 / 40 = 12 workers
i.e, we need 12 workers to do the task in 40 mins.
[ THE LOGIC HERE IS SIMPLE. MORE WORKERS IMPLIES LESS TIME, LESS WORKERS IMPLIES MORE TIME]