Problem Code: DORACAKE

Can someone help with this?
why do greedy techniques work here?

The question link

Why not for you ?, Basically, after sorting both arrays, if we pick any two indices i and j , then min(a[i],b[i]) + min(a[j],b[j]) is greater than or equal to min(a[i],b[j]) + min(a[j],b[i]) .
You can try to convince yourself for the above inequality.