← Netflix Interview Insights

Netflix·Software Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Netflix SWE interview with a bitmask DP problem that looked like a scheduling puzzle but had a lot more going on under the hood. Pretty algorithmic heavy, not much else to say about the round itself.

Questions Asked (1)

Q1

You have n courses labeled 1 through n, a list of prerequisite pairs, and an integer k representing the max courses you can take per semester. A course can only be taken if all its prerequisites were completed in strictly earlier semesters. Find the minimum number of semesters to finish all courses, or return -1 if it's not possible.

Algorithms & Data Structures
Author's notes

I knew this was a bitmask DP problem pretty quickly, which felt good for about 30 seconds until I started fumbling the state transitions.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses and prerequisites as a directed graph and use topological sorting to process courses semester by semester. In each semester, take up to k courses that have no remaining prerequisites, and if at any point no courses can be taken but courses remain, return -1. Count the number of semesters needed.

Pro tip: Clarify edge cases upfront, such as when k is larger than the number of available courses or when there are multiple valid orderings; this shows attention to detail and can guide the interviewer's expectations.

1. Model as a Graph

Represent courses as nodes and prerequisites as directed edges. Compute the in-degree (number of prerequisites) for each course.

2. Initialize Available Courses

Collect all courses with in-degree 0 into a queue or list, as these can be taken in the first semester.

3. Process Semesters

While there are available courses, take up to k courses per semester. For each taken course, reduce the in-degree of its dependents; if any dependent's in-degree becomes 0, add it to the next semester's available list.

4. Detect Cycles and Count Semesters

If at any semester no courses can be taken but courses remain, return -1 (cycle detected). Otherwise, increment the semester count until all courses are taken.

Key Points to Mention

  • Topological sorting with BFS (Kahn's algorithm) to process courses level by level.
  • Using a queue to manage courses available for the current semester.
  • Limiting to k courses per semester and handling the case where fewer than k are available.
  • Detecting cycles by checking if all courses are processed; if not, return -1.
  • Time complexity: O(V + E) where V is number of courses and E is number of prerequisite pairs.
  • Space complexity: O(V + E) for storing the graph and in-degree array.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.