← All questions
MediumCoding

Course Schedule IV

Asked atGroww
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Build directed prerequisite edges.
  2. 02Choose closure strategy from n and query count.
  3. 03Propagate prerequisite sets in topological order.
  4. 04Answer each query from the closure.
  5. 05Discuss cycles according to the contract.

Reference answer

Then expect these follow-ups

  • When would Floyd-Warshall be preferable?

    Tests: follow-up reasoning

  • How would you handle a new prerequisite edge online?

    Tests: follow-up reasoning

Hiring now

Groww is hiring right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Finance Content Creator

    Bengaluru, India

  • Relationship Manager

    India

Or practice this question first

Next question