FastPrepCourse Schedule Feasibility
Problems/Course Schedule Feasibility

Course Schedule Feasibility

Microsoft logoMicrosoft● MediumFULLTIMEINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft ML software engineer interview report recalls a question like Course Schedule I or II but does not say which one or give the exact rules. We chose Course Schedule I, which asks if the courses can be finished. Returning an ordering would be Course Schedule II. The input format and the limits follow the usual version of that exercise, not a quote from the interview.

There are numCourses courses labeled from 0 through numCourses - 1. Each pair [course, prerequisite] means the prerequisite must be completed before that course. Return true if every course can be completed in some order, or false if the dependencies contain a cycle.

Courses without prerequisites may be taken at any time. The result asks only whether a complete order exists; do not return the order itself.

Function

canFinishCourses(numCourses: int, prerequisites: int[][]) → boolean

Examples

Example 1

numCourses = 2prerequisites = [[1,0]]return = true

Take course 0 before course 1.

Example 2

numCourses = 2prerequisites = [[1,0],[0,1]]return = false

Each course requires the other first, so neither can be completed.

Example 3

numCourses = 3prerequisites = [[1,0],[2,1]]return = true

The dependency chain 0 → 1 → 2 completes all three courses.

Constraints

  • 1 <= numCourses <= 2000
  • 0 <= prerequisites.length <= 5000
  • Each prerequisite pair has exactly two course indices in [0, numCourses - 1].
  • Prerequisite pairs are unique. A self-dependency is a cycle.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Add Course Batches All or NothingAmazon · ONSITE INTERVIEW
  • Course ScheduleByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Merge Event PreferencesAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
  • Package Install OrderVerily · ONSITE INTERVIEW
  • Course SchedulePlaud · ONSITE INTERVIEW
  • Course Schedule Cycle DetectionGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Topological Sort with Secondary OrderingRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Lexicographically Smallest Course OrderLinkedIn · ONSITE INTERVIEWLinkedIn interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public boolean canFinishCourses(int numCourses, int[][] prerequisites) {
        // Write your code here
    }
}
Checking account…