⚡️ Tryprepforge
Coding Round 2 Mid programming

**LeetCode #207 - Course Schedule**\nThere are `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. Some courses may have prerequisites, forming a directed graph. Your task is to determine if you can finish all courses. If you can, return true; otherwise, return false.\n**Function Signature:** `def canFinish(numCourses: int, prerequisites: List[List[int]]) -> bool:`\n**Example 1:**\n**Input:** numCourses = 2, prerequisites = [[1,0]]\n**Output:** true\n**Explanation:** There are 2 courses, and finishing course 0 allows you to take course 1.\n**Example 2:**\n**Input:** numCourses = 2, prerequisites = [[1,0],[0,1]]\n**Output:** false\n**Explanation:** There is a circular dependency between courses 0 and 1.\n**Constraints:** 1 <= numCourses <= 2000; 0 <= prerequisites.length <= 5000; prerequisites[i].length == 2; All pairs in prerequisites are unique.

Suggested Answer

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

No credit card required

More Coding Round 2 Interview Prep

Link copied to clipboard