Course Schedule
Updated
Problem statement
Given numCourses and a list prerequisites, return true if you can finish all courses, or false if the prerequisites form a cycle.
Courses are labeled from 0 to numCourses - 1. Each pair [course, prerequisite] means you must finish prerequisite before course.
In the interview, follow-up questions covered other solutions, edge cases, and complexity.
Function
canFinish(numCourses: int, prerequisites: int[][]) → booleanExamples
Example 1
numCourses = 2prerequisites = [[1,0]]return = trueThe only rule says course zero comes before course one. Take them in that order to finish both, so the answer is true.
Example 2
numCourses = 2prerequisites = [[1,0],[0,1]]return = falseEach course needs the other one first. That is a cycle, so neither can be taken and the answer is false.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Course SchedulePlaud · ONSITE INTERVIEW
- Course ScheduleNykaa · PHONE SCREENNykaa interview questions
- Course ScheduleFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
- Course Schedule FeasibilityTesla · PHONE SCREENTesla interview questions
- Can All Courses Be FinishedC3.ai · ONSITE INTERVIEWC3.ai interview questions
- Trace Terminal Company OwnershipPalantir · ONSITE INTERVIEWPalantir interview questions
- Can You Finish All Courses?Intuit · OAIntuit interview questions
- Package Install OrderVerily · ONSITE INTERVIEW
- Task Build Order and File-Change RerunsVanta · PHONE SCREEN