I don’t know my answer was timeefficient or not, but here is my solution:
First of all, find an interval which is overlapping. I think that can be done by sorting the intervals and one forloop. So the time complexity till here is O(nlogn).
In the first case of an overlap, just take the two overlapping intervals and check whether there is a situation possible wherein you cannot shift any one of the intervals without overlapping. You can do that by storing all the ‘sizes’ of the free spaces on the cake in some vector or array and comparing the size of the intervalbeingchecked with it. If the intervals can be placed without overlapping, continue to the next part, else, print “BAD”. If shifted, make a boolean variable shifted = true;
Next part: Check again for the rest overlapping intervals. Same for the other intervals. If shifted = true, cakegood = false;
If you find any mistakes, feel free to point out. I think this was a typical brute force.
Your sample input was [1,2],[3,4],[0,4],[10,11]. Let’s go step by step.

Sort’em up. [0, 4], [1, 2], [3, 4], [10, 11].

Free Spaces: (i) (14)1<0 > NOT CONSIDERED.
(ii) (32)1=0 > NOT CONSIDERED.
(iii) (104)1 > 5 > push into sizes vector.

Overlapping Intervals: [0,4] & [1, 2], [0, 4] & [3, 4] .

Overlapping sizes: (40)+1 = 5; (21)+1 = 2;

Size 5 is present in vector sizes. Can be shifted. Cakegood = true; shifted = true;

Next Overlapping Items: [0,4] & [3,4].

shifted = true; cakegood = false;

Next Overlapping Items: None.

Print output: Cakegood > BAD.
Peace.