FastPrepCourse Schedule Feasibility
Problems/Course Schedule Feasibility

Course Schedule Feasibility

Tesla logoTesla● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Tesla software engineer intern interview. The report only recalls a simpler task like Course Schedule. Our version asks whether all the courses can be finished. It is about 70% the same as the reported question.

You need to complete numCourses courses labeled from 0 to numCourses - 1.

Each pair [course, prerequisite] means that prerequisite must be completed before course.

Return true if it is possible to complete every course. Otherwise, return false.

Function

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

Examples

Example 1

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

Take course 0 first, then course 1.

Example 2

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

Each course requires the other first, so the prerequisite graph contains a cycle.

Example 3

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

The order 0, 1, 2, 3 completes every course.

Constraints

  • 1 <= numCourses <= 2,000.
  • 0 <= prerequisites.length <= 5,000.
  • Every prerequisite pair contains two valid course labels.
  • A course is never listed as its own prerequisite.

More Tesla Phone Screen questions

  • Flatten a Branched List into a Doubly Linked ListPHONE SCREEN · Seen Sep 2026
  • Reduce-Based Map and Filter PipelinePHONE SCREEN · Seen Sep 2026
  • Resilient Fake API ClientPHONE SCREEN · Seen Sep 2026
  • Merge JSON Array FieldsPHONE SCREEN · Seen Aug 2026
  • KV Store with RollbackPHONE SCREEN · Seen Apr 2026
  • Multi-Channel Valid ConvolutionPHONE SCREEN · Seen Oct 2024
  • Average of a Fixed-Size ArrayPHONE SCREEN · Seen Jun 2024
  • Swap Even and Odd BitsPHONE SCREEN · Seen Mar 2023
  • Find the Intersection Node of Two Linked ListsPHONE SCREEN · Seen Oct 2022
  • Priority, Expiration, and LRU EvictionPHONE SCREEN · Seen Mar 2021

Similar questions at other companies

  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Course ScheduleNykaa · PHONE SCREEN
  • Course ScheduleBloomberg LP · PHONE SCREEN · ONSITE INTERVIEW
  • Course ScheduleOracle · ONSITE INTERVIEW
  • Course SchedulePlaud · ONSITE INTERVIEW
  • Course ScheduleFlexTrade · ONSITE INTERVIEW
  • Can You Finish All Courses?Intuit · OA
  • Can All Courses Be FinishedC3.ai · ONSITE INTERVIEW
  • Trace Terminal Company OwnershipPalantir · ONSITE INTERVIEW
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
See Tesla hiring insights
Saved
class Solution {
    public boolean canFinishCourses(int numCourses, int[][] prerequisites) {
      // write your code here
    }
}
Checking account…