Course Schedule
Updated
Problem statement
There are numCourses courses labeled from 0 to numCourses - 1. Each pair [course, prerequisite] means the prerequisite must be completed before the course.
Return true if all courses can be completed, or false if the prerequisite graph contains a cycle.
Interview Follow-up
The interviewer asked follow-up questions about alternative solutions, edge cases, and complexity analysis.
Function
canFinish(numCourses: int, prerequisites: int[][]) → booleanExamples
Example 1
numCourses = 2prerequisites = [[1,0]]return = trueExample 2
numCourses = 2prerequisites = [[1,0],[0,1]]return = falseEach course requires the other first, creating a cycle.
Source note: Author-written prompt excerpt retained for source fidelity.
More Nykaa interview questions
- Employees Who Earn More Than Their ManagersPHONE SCREEN · Seen Nov 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Nov 2026
- Remove Duplicates from Sorted ArrayPHONE SCREEN · Seen Nov 2026
- Max Consecutive Ones IIIPHONE SCREEN · Seen Sep 2026
- Reverse a String Keeping Dashes in PlaceONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Course ScheduleBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Course Schedule FeasibilityTesla · PHONE SCREENTesla interview questions
- Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
- Course SchedulePlaud · ONSITE INTERVIEW
- Course ScheduleFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
- Can You Finish All Courses?Intuit · OAIntuit interview questions
- Can All Courses Be FinishedC3.ai · ONSITE INTERVIEWC3.ai interview questions
- Trace Terminal Company OwnershipPalantir · ONSITE INTERVIEWPalantir interview questions
- Task Build Order and File-Change RerunsVanta · PHONE SCREEN