In this post, we are going to discuss leetcode 1136 — Parallel Courses, which is asked in Meta interviews.
Problem Analysis
You are given an integer
n
, which indicates that there aren
courses labeled from1
ton
. You are also given an arrayrelations
whererelations[i] = [prevCoursei, nextCoursei]
, representing a prerequisite relationship between courseprevCoursei
and coursenextCoursei
: courseprevCoursei
has to be taken before coursenextCoursei
.In one semester, you can take any number of courses…