This will be a pretty computation intensive task. You would basically split all episodes, such that there are no overlaps left. This can be done by duplicating each overlapping row after sorting for start and end time and then adjusting.
In your example you would make a larger dataset, namely with A duplicated twice, adjusting the time of A1 to actual start up to beginning of B, then A2 congruent to B and lastly A3 beginning with end of B up to the actual end.
After that is done, you have to identify congruent intervals and flag them, then calculate durations of those intervals.
In the last step you would collapse the data back to actual start and end, but summing all count flags and durations to one value.
Since you could have infinitely many overlapping intervals, depending on the number of persons you have, you will have to think about a lot of cases which could break the above thoughts. You will also need a lot of flags to find out, which intervals overlap in what way, since there are four possibilities you have to account for.
So it is definitely possible, but really not trivial and potentially problematic regarding computational resources, given the possible infinitely many overlaps.