Netflix Onsite | SWE | HM
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2023-08-24Added By Anonymous
Source: Link
Company: Netflix
Role: SWE
Interview Stage: Onsite
Location: unknown
Year: unknown
Original Post Content:
Problem Statement: Task Scheduler with Buffered Execution
You are tasked with designing a system, named TaskProcessor, that efficiently handles a stream of tasks. The system should ensure that when a certain number of tasks accumulate (e.g., a batch of 10), they are processed or flushed for execution. It should also have mechanisms to deal with large influxes of tasks and ensure smooth processing.
class TaskProcessor {
public:
TaskProcessor();
// Adds a new task to the processor
void runTask(std::function<void()> task);
// Processes accumulated tasks
void flushTasks();
};