Category: String coding problemYou 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
codingMediumVerified Question#2
2. Region Grid Coloring
Category: Grid/matrix coding problemYou 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
codingMediumVerified Question#3
3. Parallel Task Batching
Category: Graph coding problemA 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
codingMediumVerified Question#4
4. Maximum Interval Overlap
Category: Interval-based coding problemYou 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
codingHardVerified Question#5
5. Interval Coverage Counter
Category: Interval-based coding problemGiven 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
codingEasyVerified Question#6
6. [CodeSignal] Movie Group Ranker
Category: Array coding problemYou 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
codingEasyVerified Question#7
7. [CodeSignal] One-Hot Encoder
Category: Matrix coding problemGiven 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
codingMediumVerified Question#8
8. Event Rate Limiter
Category: String coding problemDesign 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
codingMediumVerified Question#9
9. Viewing History Friends
Category: Algorithm coding problemA streaming platform groups customers together based on shared viewing habits. You receive: - customerIds - a list of distinct customer IDs -...Input: List Output: Array
codingHardVerified Question#10
10. Weight-Based Cache
Category: String coding problem
Weight-Based Cache
Input: List Output: Computed result
codingHardgraph#1
1. [OA] Graph Traversal — Optimize genre recommendations for users
To enhance user experience and engagement, Netflix needs a system to recommend new content based on users’ viewing histories and preferences. It’s essential to identify connections between different genres and what combinations drive user engagement. Given a directed graph represented by an adjacency list where nodes represent genres and edges indicate recommended connections, implement a function to traverse the graph and return all genres reachable from the source genre in a list.
Implement getRecommendedGenres(genres: List[List[int]], start: int) -> List[int] which outputs all genres reachable from the start genre in any order.
Example 1: Input: genres = [[1,2],[2,3],[3,4],[5],[]], start = 0 Output: [1, 2, 3, 4] Explanation: Starting from genre 0, we can reach genres 1, 2, 3, and 4 through multiple recommendations.Example 2: Input: genres = [[1,2],[],[3],[],[]], start = 1 Output: [] Explanation: Genre 1 has no further recommendations.Constraints:
1 <= len(genres) <= 1000
0 <= genres[i].length <= 100
codingHardsliding window#2
2. [OA] Sliding Window — Track user viewing sessions in real-time
In a dynamic streaming platform like Netflix, understanding user engagement through the length of current viewing sessions is crucial for optimizing content delivery and recommendations. Given a list of int representing session durations where each duration is the time in seconds a user has spent watching content, return the maximum number of unique sessions in any continuous window of time.
You need to implement a function maxUniqueSessions(durations: List[int], k: int) -> int that returns an int representing the maximum number of unique sessions in any window of length k.
Example 1: Input: durations = [1, 2, 3, 2, 4, 1], k = 4 Output: 4 Explanation: The unique sessions in the window of the last four durations are 2, 3, 4, 1, resulting in four unique sessions.Example 2: Input: durations = [3, 3, 3, 3, 3], k = 2 Output: 1 Explanation: All durations are the same; hence, the maximum unique sessions is 1.Constraints:
1 <= len(durations) <= 10^5
0 <= durations[i] <= 10^5
1 <= k <= len(durations)
system designSeniorapi design#3
3. [OA] Class Design — Create a WatchList system for users
To enhance user engagement and content discoverability, Netflix aims to implement a user-specific watchlist system allowing users to save their preferred content for future viewing. Design a class WatchList that allows users to manage their watchlist with the following features:
add(contentId: string): Adds a content ID to the watchlist.
remove(contentId: string): Removes a content ID from the watchlist.
getAll() -> List[string]: Returns a list of all content IDs in the watchlist.
contains(contentId: string) -> bool: Checks if a content ID is present in the watchlist.
Example 1: Input: watchlist = new WatchList(); watchlist.add('content123'); watchlist.getAll() Output: ['content123'] Explanation: The content ID 'content123' is successfully added to the watchlist.Constraints:
As Netflix's platform scales, creating a seamless user experience necessitates designing an efficient client-side routing system to manage navigation and view states across the application. Implement a class Router to manage routes and navigation within the application, with the following functionality:
addRoute(path: string, component: Function) -> void: Adds a new route with an associated component.
navigate(path: string) -> void: Navigates to the specified route, rendering the associated component.
getCurrentRoute() -> string: Returns the current route.
Example 1: Input: router = new Router(); router.addRoute('/home', Home); router.addRoute('/about', About); router.navigate('/home'); router.getCurrentRoute() Output: '/home' Explanation: Navigating to '/home' renders the Home component and updates the current route to '/home'.Constraints:
All path strings are unique.
Each component is a valid Function reference.
Concurrent navigation requests may occur, which should be handled gracefully.