I was asked this question during Amazon onsite interview.
You have given students and their courses taken, find the minimum number of slots required.
Example: std1 -> A, B, C
std2 -> B
std3 -> E, F, G
std4 -> A, F
So the minumum would be 6 i.e. A, B, C, E, F, G
I tried a little variation of Union find, but couldn't complete it. Any response or similar Leetdcode example is greatly appreciated.