Algorithm · Google · Hard
This interview task has three related variants centered on ordering items under constraints. Course-ordering variant Solve the course-ordering problem. Beyond producing an answer, the interviewer expects you to cover how an ordering is checked for validity, the time and space complexity of your approach, and a set of test cases. Then extend your result so that it is returned as a nested list. The rule for how items are grouped into inner lists is deliberately left…