Netflix logo

Netflix Software Engineer Interview Questions

45 practice questions for Netflix Software Engineer interviews

Netflix software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Easy Verified Question #1

1. Label Co-occurrence Finder


Category: String coding problem
You are given a list of label groups and a list of required labels. Each group is a list of strings. A group is considered valid if it contains every...
Input: Array of strings
Output: Array
Want to practise this one?
Create a free account to open the full question and practise Netflix questions with AI.
Sign up free
coding Medium Verified Question #2

2. Region Grid Coloring


Category: Grid/matrix coding problem
You are given an M x N grid of security zones. Each cell contains one of the following values: - 1 -- the zone is cleared - 0 -- the zone...
Input: 2D grid
Output: Computed result
coding Medium Verified Question #3

3. Parallel Task Batching


Category: Graph coding problem
A pipeline must execute a set of tasks with dependency constraints. Each dependency [A, B] means task A must complete before task B can start....
Input: Graph (nodes and edges)
Output: Computed result
coding Medium Verified Question #4

4. Maximum Interval Overlap


Category: Interval-based coding problem
You are given a list of closed intervals on the number line, where each interval [start, end] includes both endpoints. Find the maximum number of...
Input: List
Output: Integer
coding Hard Verified Question #5

5. Interval Coverage Counter


Category: Interval-based coding problem
Given a list of closed intervals on the integer number line, build a data structure that efficiently answers point-coverage queries. A closed...
Input: List
Output: Computed result
coding Easy Verified Question #6

6. [CodeSignal] Movie Group Ranker


Category: Array coding problem
You are building a movie recommendation system. Given a source movie a user liked, you receive: - An array scores where scores[i] is the...
Input: Array
Output: Integer
coding Easy Verified Question #7

7. [CodeSignal] One-Hot Encoder


Category: Matrix coding problem
Given an integer array arr, return its one-hot encoded matrix as a 2D array. In a one-hot encoding: - Each row represents one element from arr. -...
Input: Matrix (2D array)
Output: Computed result
coding Medium Verified Question #8

8. Event Rate Limiter


Category: String coding problem
Design a rate-limited event logger for a streaming system. Events arrive in non-decreasing timestamp order. The system must suppress an event name if...
Input: String
Output: Printed output
coding Medium Verified Question #9

9. Viewing History Friends


Category: Algorithm coding problem
A streaming platform groups customers together based on shared viewing habits. You receive: - customerIds - a list of distinct customer IDs -...
Input: List
Output: Array
coding Hard Verified Question #10

10. Weight-Based Cache


Category: String coding problem

Weight-Based Cache

Input: List
Output: Computed result
coding Hard caching #1

1. [AI Enabled Coding] Playback Metadata Cache Policies


Scenario


Netflix clients need timely playback manifests and personalized artwork metadata; serving expired metadata can expose outdated playback URLs or the wrong artwork variant. Implement a deterministic, in-memory cache simulator for an engineering team evaluating expiration and eviction policies across these metadata namespaces. You may use an AI assistant while coding, but you must verify its data structures, policy ordering, and boundary behavior.

Part 1 — Expiration and recency


  • Input is a list of maps with string keys and string values, processed in input order. Every record contains op, time_ms, namespace, and key; op is PUT or GET. Times are nondecreasing.

  • A cache identity is the pair (namespace, key). Different namespaces may use the same key independently.

  • PUT also contains value and bytes, where bytes is a positive decimal integer representing the metadata's measured footprint. An optional positive ttl_ms overrides the default TTL of 1000 milliseconds.

  • Before every operation, remove every entry whose expires_at <= time_ms. Set expires_at = time_ms + ttl_ms on each successful PUT; a GET never renews TTL.

  • The default capacity is 3 live entries, configurable through max_entries. A successful PUT inserts or replaces an entry and makes it most recently used. A successful GET also makes its entry most recently used. Misses do not change recency.

  • After a PUT, evict the globally least recently used entries until the entry limit is satisfied. Input order breaks recency ties, including operations with identical timestamps.

  • Return STORED for a successful PUT, HIT with the stored value for a successful GET, and MISS otherwise. Your return type is up to you; the examples use a list of result objects.


Function signature: simulate_cache(records: list[dict[str, str]], max_entries: int = 3); return type is up to the candidate.

Example 1:


Input:
{
  "records": [
    {"op": "PUT", "time_ms": "0", "namespace": "artwork", "key": "title-1:en", "value": "image-A", "bytes": "2"},
    {"op": "GET", "time_ms": "5", "namespace": "artwork", "key": "title-1:en"},
    {"op": "GET", "time_ms": "6", "namespace": "manifest", "key": "title-1:en"},
    {"op": "PUT", "time_ms": "7", "namespace": "artwork", "key": "title-1:en", "value": "image-B", "bytes": "3", "ttl_ms": "10"},
    {"op": "GET", "time_ms": "17", "namespace": "artwork", "key": "title-1:en"}
  ]
}

Output:
[
  {"status": "STORED"},
  {"status": "HIT", "value": "image-A"},
  {"status": "MISS"},
  {"status": "STORED"},
  {"status": "MISS"}
]

Explanation: The manifest lookup does not match the artwork namespace. Replacing the artwork changes its expiration to 7 + 10 = 17; it is expired exactly at time 17.

Part 2 — Independently owned namespace budgets


The artwork, manifest, and subtitle teams now need independent byte budgets as well as a shared memory ceiling. Extend Part 1 rather than replacing it. The approach must be flexible enough to support future namespaces and additional eviction policies. Discuss how your return type changes before implementing this extension.
  • Keep all Part 1 behaviors, including the entry limit. Enable this extension with part=2.

  • Add max_bytes, default 10, as the global live-byte limit. Every namespace has a default live-byte limit of 6. Optional namespace_limits records such as {"namespace":"artwork","max_bytes":"8"} override that namespace's limit.

  • Perform expiration cleanup first, even if the operation will subsequently be rejected. Report expired removals in ascending order of (expires_at, namespace, key) using lexicographic string ordering.

  • Before modifying a PUT target, reject it if its individual bytes exceeds its namespace limit or the global byte limit. Return REJECTED and all violated policy names, ordered NAMESPACE_BYTES, then GLOBAL_BYTES. Equality is allowed. Rejection must preserve any still-live old value and must not refresh its recency or TTL.

  • Otherwise, replace or insert the entry, mark it most recently used, and enforce policies in this exact order: namespace bytes, global bytes, global entry count. While a policy is violated, evict its least recently used eligible entry. Namespace enforcement considers only the written namespace; the other policies consider all entries.

  • Report each removal with its namespace, key, and the first policy that actually removed it: EXPIRED, NAMESPACE_BYTES, GLOBAL_BYTES, or ENTRY_COUNT. A replacement is not a reported removal. Expiration removals precede capacity removals.

  • Each operation now includes a removed list, even when empty. Return final resident entry and byte counts as well. These counts reflect the time of the last operation, without advancing the clock afterward.


Extended signature: simulate_cache(records: list[dict[str, str]], max_entries: int = 3, *, part: int = 1, max_bytes: int = 10, namespace_limits: list[dict[str, str]] | None = None); discuss and choose the return type.

Example 2:


Input:
{
  "part": 2,
  "records": [
    {"op": "PUT", "time_ms": "0", "namespace": "artwork", "key": "a", "value": "A", "bytes": "4"},
    {"op": "PUT", "time_ms": "1", "namespace": "manifest", "key": "m", "value": "M", "bytes": "4"},
    {"op": "PUT", "time_ms": "2", "namespace": "artwork", "key": "b", "value": "B", "bytes": "3"},
    {"op": "GET", "time_ms": "3", "namespace": "manifest", "key": "m"},
    {"op": "PUT", "time_ms": "4", "namespace": "subtitle", "key": "s", "value": "S", "bytes": "4"}
  ]
}

Output:
{
  "results": [
    {"status": "STORED", "removed": []},
    {"status": "STORED", "removed": []},
    {"status": "STORED", "removed": [{"namespace": "artwork", "key": "a", "reason": "NAMESPACE_BYTES"}]},
    {"status": "HIT", "value": "M", "removed": []},
    {"status": "STORED", "removed": [{"namespace": "artwork", "key": "b", "reason": "GLOBAL_BYTES"}]}
  ],
  "resident": {"entries": 2, "bytes": 8}
}

Explanation: Inserting b initially produces artwork usage 4 + 3 = 7 > 6 and global usage 4 + 4 + 3 = 11 > 10. Namespace enforcement runs first and removes a, reducing global usage to 7, so no global eviction is needed at that step. Reading m makes it newer than b. Inserting s produces 3 + 4 + 4 = 11 bytes; global enforcement removes b, leaving m and s with 4 + 4 = 8 bytes.

Example 3:


Input:
{
  "part": 2,
  "records": [
    {"op": "PUT", "time_ms": "0", "namespace": "artwork", "key": "a", "value": "A", "bytes": "4", "ttl_ms": "10"},
    {"op": "PUT", "time_ms": "1", "namespace": "manifest", "key": "m", "value": "M", "bytes": "5"},
    {"op": "PUT", "time_ms": "2", "namespace": "artwork", "key": "a", "value": "too-large", "bytes": "11"},
    {"op": "GET", "time_ms": "3", "namespace": "artwork", "key": "a"},
    {"op": "PUT", "time_ms": "10", "namespace": "subtitle", "key": "s", "value": "S", "bytes": "1"},
    {"op": "GET", "time_ms": "10", "namespace": "artwork", "key": "a"}
  ]
}

Output:
{
  "results": [
    {"status": "STORED", "removed": []},
    {"status": "STORED", "removed": []},
    {"status": "REJECTED", "violations": ["NAMESPACE_BYTES", "GLOBAL_BYTES"], "removed": []},
    {"status": "HIT", "value": "A", "removed": []},
    {"status": "STORED", "removed": [{"namespace": "artwork", "key": "a", "reason": "EXPIRED"}]},
    {"status": "MISS", "removed": []}
  ],
  "resident": {"entries": 2, "bytes": 6}
}

Explanation: The attempted replacement breaks both individual-size rules because 11 > 6 and 11 > 10. It is rejected without deleting the original 4-byte value, so resident usage remains 4 + 5 = 9. The later hit does not renew its TTL. At time 10, expiration removes 4 bytes before the subtitle insertion adds 1 byte, leaving 9 - 4 + 1 = 6 bytes across two entries.

Notes:


  • There are at most 200,000 operations. Numeric strings contain integers between 0 and 10^12; sizes, TTLs, and configured limits are positive. Records are valid, and namespace overrides have unique names.

  • bytes is supplied metadata, not the length of value. Capacities are configurable and may be large; avoid scanning the whole cache on each operation. Aim for O(n log n) total processing time, excluding string comparison costs.

  • Execution is single-threaded with no background cleanup. Namespace limits do not change during a call; an empty input returns no operation results and zero resident entries and bytes in Part 2.
Want to practise this one?
Create a free account to open the full question and practise Netflix questions with AI.
Sign up free
coding Hard caching #2

2. [Caching] — Implement a bounded TTL cache with LRU eviction


Background
Netflix services can cache title metadata used to render browsing pages, reducing repeated backend requests. Such a cache needs expiration to limit stale metadata and a capacity limit to prevent unbounded memory growth. This problem adapts a reported Netflix interview exercise involving TTL caching, LRU eviction, and concurrency.
Problem statement
Implement TTLCache, an in-memory cache mapping string title IDs to integer metadata-version values. The cache holds at most capacity live entries and combines per-entry time-to-live (TTL) with least recently used (LRU) eviction.
Each operation receives an explicit integer timestamp now, measured in milliseconds. Timestamps are nondecreasing across all operations on an instance; do not use the system clock.
A put(key, value, ttl, now) inserts or replaces an entry whose expiration timestamp is now + ttl. An entry is expired when now >= expiration. Replacing an existing live entry resets its value and expiration, and makes it most recently used. An old expiration record must never invalidate a newer version of the same key.
A get(key, now) returns the value of a live entry and makes it most recently used. It returns None for a missing or expired entry. A miss does not change the relative recency of live entries.
Before processing either operation, discard all expired entries. When inserting a new key into a full cache, evict the least recently used live entry. Expired entries must never cause an otherwise unnecessary live-entry eviction. If multiple operations have the same timestamp, their call order determines recency.
Support O(log(capacity + 1)) amortized time per operation and O(capacity) total auxiliary storage, including expiration bookkeeping. Scanning the entire cache on every operation is not acceptable, and repeatedly updating one key must not cause unbounded expiration-record growth. An individual operation may do more work when reclaiming accumulated expired entries.
Function or class signature
  • TTLCache(capacity: int) — construct an empty cache.

  • put(key: str, value: int, ttl: int, now: int) -> None — insert or replace an entry.

  • get(key: str, now: int) -> int | None — return a live value or None.


Example 1:
Input:
{
  "operations": ["TTLCache", "put", "put", "get", "put", "get", "get", "get"],
  "arguments": [[2], ["title-A", 10, 5, 0], ["title-B", 20, 10, 1], ["title-A", 2], ["title-C", 30, 10, 3], ["title-B", 4], ["title-A", 5], ["title-C", 5]]
}

Output:
[null, null, null, 10, null, null, null, 30]

Explanation: A expires at time 5 and B at time 11. Reading A at time 2 makes B least recently used, so inserting C at time 3 evicts B. A is expired exactly at time 5, while C remains live until time 13. Constructor and put results are represented by null.
Example 2:
Input:
{
  "operations": ["TTLCache", "put", "put", "put", "get", "put", "get", "get", "get"],
  "arguments": [[2], ["title-A", 1, 3, 0], ["title-A", 2, 10, 1], ["title-B", 3, 20, 2], ["title-A", 3], ["title-C", 4, 1, 4], ["title-B", 4], ["title-C", 5], ["title-A", 11]]
}

Output:
[null, null, null, null, 2, null, null, null, null]

Explanation: Updating A changes its expiration from 3 to 11. Its obsolete expiration at time 3 must not remove the updated value. The successful read at time 3 makes B least recently used, so C evicts B. C expires exactly at time 5, and A expires exactly at time 11.
Constraints:
  • 1 <= capacity <= 100000.

  • At most 200000 calls to get and put per instance.

  • Keys are strings of length 1 through 100.

  • Values are integers in [-10^9, 10^9]; None is reserved for a miss.

  • 1 <= ttl <= 10^12 and 0 <= now <= 10^12; use an integer type that can hold now + ttl.

  • Calls are initially single-threaded, and timestamps are nondecreasing.


Follow-up:
How would you make get and put linearizable when multiple request threads share the cache? Explain which expiration, lookup, recency, and eviction steps must be atomic, and how timestamps should be assigned when lock-acquisition order differs from request-arrival order.
coding Medium file management #3

3. Coding — Implement an In-Memory File System

Background: Netflix requires efficient data storage and retrieval for the vast number of media files. An in-memory file system can help model how files are organized and accessed without relying on a physical disk.
Problem statement: You need to implement a basic in-memory file system that supports the following operations:
1. mkdir(String path): Create a directory at the specified path.
2. addContentToFile(String filePath, String content): Create a file at the specified path and add the given content to it. If the file already exists, append the content.
3. readContentFromFile(String filePath): Read and return the content of the file at the given path. If the file does not exist, return an empty string.
Function/class signature:
  • def mkdir(self, path: str) -> None:

  • def addContentToFile(self, filePath: str, content: str) -> None:

  • def readContentFromFile(self, filePath: str) -> str:

Example 1:
Input:
mkdir('/a')
addContentToFile('/a/b.txt', 'hello')
addContentToFile('/a/b.txt', ' world')
readContentFromFile('/a/b.txt')
Output:
'hello world'
Explanation: The file /a/b.txt is created and contains 'hello'. After appending ' world', it contains 'hello world'.
Example 2:
Input:
mkdir('/c/d')
readContentFromFile('/c/d/e.txt')
Output:
''
Explanation: The file /c/d/e.txt does not exist, hence it returns an empty string.
Constraints:
  • Each path component (after splitting by '/') will be non-empty and contain only letters.

  • Path will start with a '/'.

  • Length of path will be at most 100 characters.

  • The number of operations will be at most 10^4.
coding Medium string #4

4. Coding Problem — String to Integer Conversion

Background: Netflix handles a vast amount of data, and efficient data parsing is essential for performance in streaming applications. A common requirement is converting user input strings into integers safely and efficiently.
Problem statement: Implement a function my_atoi that converts a string s into an integer. The function should ignore leading whitespace and handle optional '+' or '-' signs. It should return the converted integer, and clamp the value within the limits of a 32-bit signed integer. If s is invalid, return 0.
Function/class signature:
  • def my_atoi(s: str) -> int:

Example 1:
  • Input: " -42"

  • Output: -42

  • Explanation: The leading spaces are ignored, and the negative sign is parsed correctly.

Example 2:
  • Input: "4193 with words"

  • Output: 4193

  • Explanation: Only the leading numeric part is considered before the non-numeric characters appear.

Constraints:
  • The input string consists of English letters (upper/lowercase), digits, and spaces.

  • The conversion should respect 32-bit signed integer limits: [-2^31, 2^31 - 1].
coding Medium string #5

5. Coding Problem — Implement string to integer conversion

Background: In a platform like Netflix, efficient data processing and manipulation are crucial for handling user input and search functionalities. This problem relates to parsing and converting user input strings into usable integer values, akin to handling identifiers or counts.
Problem statement: Write a function that converts a string s to an integer according to the rules of the ASCII values of characters. The function should ignore any leading whitespace, handle optional leading + or - signs, and should not overflow (return the maximum or minimum value for int). You may assume that the input will always be a valid integer format within the bounds of a 32-bit signed integer.
Function/class signature:
  • def myAtoi(s: str) -> int:


Example 1:
  • Input: " -42"

  • Output: -42

  • Explanation: The whitespace is ignored, and the leading - indicates the number is negative.


Example 2:
  • Input: "4193 with words"

  • Output: 4193

  • Explanation: The function parses the leading integer until it hits a non-digit character.


Constraints:
  • 0 <= s.length <= 200

  • The resulting integer should be within the range of a 32-bit signed integer: [-2^31, 2^31 - 1].

  • The input string will only contain printable ASCII characters.


**
system design Medium #6

6. Design InMemoryFileSystem — simulated file system operations

Background: Netflix requires efficient storage and management for user-generated content and temporary files in its platform. A well-defined in-memory file system allows quick access and manipulation of files without the need for disk IO, enhancing performance.
Requirements:
1. Implement mkdir(path: str) to create directories.
2. Implement addContentToFile(filePath: str, content: str) to add content to files, creating the file if it does not exist.
3. Implement readContentFromFile(filePath: str) -> str to read the content of a file.
4. Implement ls(path: str) -> List[str] to list files and directories in a given path in lexicographical order.
Class API:
  • mkdir(path: str) -> None - Creates directories.

  • addContentToFile(filePath: str, content: str) -> None - Adds content to a file.

  • readContentFromFile(filePath: str) -> str - Returns the content of the specified file.

  • ls(path: str) -> List[str] - Lists files/directories in the path.

Example 1:
Input:
mkdir('/a')
addContentToFile('/a/b.txt', 'hello')
addContentToFile('/a/b.txt', ' world')
readContentFromFile('/a/b.txt')
Output: 'hello world'
Explanation: The file /a/b.txt was created and content was added successfully, returning the correct concatenated string.
Example 2:
Input:
mkdir('/c/d')
ls('/c')
Output: ['d']
Explanation: The directory d exists under c, showing a correct list of directories.
Constraints:
  • Max depth of directories: 10

  • Max length of file path: 100

  • Max content per file: 1024 characters
system design Medium api design #7

7. Design InMemoryFileSystem — a simplified file system in memory

Background: Netflix operates with vast amounts of data and content that need efficient access and manipulation. An in-memory file system allows for fast temporary storage and rapid development of features. This system would simulate the behavior of a file system to manage content effectively.
Requirements:
1. Must support creating a directory structure with mkdir(path).
2. Must allow listing files in a directory with ls(path).
3. Must enable adding content to a file with addContentToFile(filePath, content).
4. Must allow reading the content of a file with readContentFromFile(filePath).
5. Handle non-existing paths gracefully.
Class API:
  • def mkdir(path: str) -> None: Creates a new directory at the specified path.

  • def ls(path: str) -> List[str]: Returns a list of files/directories in the specified path.

  • def addContentToFile(filePath: str, content: str) -> None: Appends content to the specified file.

  • def readContentFromFile(filePath: str) -> str: Returns the content of the specified file.

Example 1:
Input: mkdir('/a')
Output: None
Explanation: Creates directory /a.
Input: addContentToFile('/a/b.txt', 'hello')
Output: None
Explanation: Creates file /a/b.txt with content hello.
Input: ls('/a')
Output: ['b.txt']
Explanation: Lists files in directory /a.
Example 2:
Input: mkdir('/c/d/e')
Output: None
Explanation: Creating nested directories should work, thus /c/d/e is created from scratch.
Constraints:
  • Maximum of 1000 directories and files.

  • File names can be up to 100 characters long.

  • Paths are guaranteed to be valid as per Unix file path rules.

system design Medium api design #8

8. Design InMemoryFileSystem: A file system that allows basic file operations in memory

Background: Netflix needs an in-memory file system to simulate and test features relevant to streaming and content storage without relying on disk I/O. This helps in optimizing performance and facilitating faster iterations during development.
Requirements:
1. Implement a method mkdir(path: str), which creates a directory at the specified path.
2. Implement a method ls(path: str) -> List[str], that lists all files and directories at the specified path in alphabetical order.
3. Implement a method addContentToFile(filePath: str, content: str), which adds content to a file; if the file does not exist, it should create it.
4. Implement a method readContentFromFile(filePath: str) -> str, which reads and returns the content of the specified file.
Class API:
  • mkdir(path: str) -> None: Creates a directory at the specified path.

  • ls(path: str) -> List[str]: Returns a list of the files and directories at the specified path.

  • addContentToFile(filePath: str, content: str) -> None: Adds content to the file or creates it if it doesn’t exist.

  • readContentFromFile(filePath: str) -> str: Reads the content of the specified file.

Example 1:
Input: mkdir('/a') → Output: None → Explanation: A directory /a is created.
Input: addContentToFile('/a/b.txt', 'hello') → Output: None → Explanation: A new file /a/b.txt is created with content 'hello'.
Input: readContentFromFile('/a/b.txt') → Output: 'hello' → Explanation: Content from the file is retrieved successfully.
Example 2:
Input: addContentToFile('/a/b.txt', ' world') → Output: None → Explanation: Content is appended to the file, now /a/b.txt contains 'hello world'.
Constraints:
  • Up to 1000 directories or files can be created.

  • Directory and file names will only contain lowercase letters or the special character, /.

  • The file size will not exceed 1MB.

  • All operations should be done in reasonable time (O(log n) for searches).
system design Medium api design #9

9. Design Digital Library — a simple library system for managing book information and lending operations.


Background: Netflix aims to enhance user engagement through varied content formats, including literature. A digital library system can help users access books easily while keeping track of lending history.
Requirements:
1. Must support adding, removing, and searching books by title or author.
2. Should allow users to check out and return books, updating the status accordingly.
3. Maintain a list of all borrowers and their borrowed books.
4. Implement a method to get the most borrowed books.
5. Ensure thread safety when multiple users access the library simultaneously.
Class API:
  • add_book(title: str, author: str) -> None: Adds a book to the library.

  • remove_book(title: str) -> None: Removes a book from the library.

  • checkout_book(title: str, user: str) -> bool: Checks out a book to a user.

  • return_book(title: str, user: str) -> bool: Returns a book borrowed by a user.

  • get_most_borrowed() -> List[str]: Returns a list of the most borrowed books.


Example 1:
Input:
add_book('1984', 'George Orwell')
checkout_book('1984', 'User1')
Output:
True
Explanation: Book '1984' is successfully checked out by 'User1'.
Example 2:
Input:
return_book('1984', 'User1')
Output:
True
Explanation: Book '1984' is successfully returned by 'User1'.
Constraints:
  • Maximum of 10,000 books.

  • Maximum of 1,000 concurrent users.

  • Book titles must be unique within the library.

Related Netflix Software Engineer interview prep

Start practicing Netflix questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free