Return the optimal time slot
Yes, code can be optimized to O(slotsA.length + slotsB.length) asumming that slotsA and slotsB are already sorted and the time ranges in each input do not overlap (which seems to be the case from your example).
Haven´t tested code and there are probably some edge cases missing but it should give you the idea:
    int idxA, idxB = 0;
    int maxStartDur, minEndDur, overlap;
    
    while (idxA &lt; slotsA.length &amp;&amp; idxB &lt; slotsB.length) {
        maxStartDur = Math.max(slotsA[idxA][0],slotsB[idxB][0]);
        minEndDur = Math.min(slotsA[idxA][1], slotsB[idxB][1]);
        overlap =  minEndDur - maxStartDur;
        
        if (overlap &gt;= dur) {
            optTime[0] = maxStartDur;
            optTime[1] = maxStartDur + dur;
            return optTime;
        }
        
        if (slotsA[idxA][1] &gt; slotsB[idxB][1]) {
            idxB += 1;
        } else {
            idxA += 1;
        }
        
    }

In your case, you start with 10-50 and 0-15. It did not give enough overlap. Is it worth comparing 0-15 with the other slotA ranges? No, because the others will start at more than 50, and they won't overlap.
Is it worth comparing 10-50 with other slotB ranges? Yes, because there could be a 20-30 range afterwards. Basically, 50 is greater than 15, so thats our hint that we can keep growing that 15 going to next range from slotB and as long as its less than 50, we might keep having an overlap.
If you keep doing this, you will arrive at desired answer.
There might be data structures suited for this, but it is still simple enough to not need one.