PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snowflake

Implement course scheduling and rate limiter analysis

Last updated: Mar 29, 2026

Quick Overview

This combined question evaluates proficiency in graph-based dependency reasoning (cycle detection and course scheduling) and time-series request processing (rate-limiter behavior and sliding-window request counting) within the Coding & Algorithms domain.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Implement course scheduling and rate limiter analysis

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given two independent coding problems. --- ### Problem 1: Course Scheduling You are planning to take a set of courses and are given prerequisite relationships between them. - There are `n` courses labeled from `0` to `n - 1`. - You are given a list of prerequisite pairs `prerequisites`, where each pair `[a, b]` means you must complete course `b` before you can take course `a`. #### Task A Determine whether it is possible to finish all `n` courses. - Return `true` if you can complete all courses (i.e., the prerequisite graph has no cycle); otherwise return `false`. You should specify the time and space complexity of your algorithm. #### Task B (Follow-up) Assume: - Each course takes exactly one semester to complete. - In any given semester, you may take any number of courses, as long as you have completed all of their prerequisites in earlier semesters. If it is possible to finish all courses, compute the **minimum number of semesters** required to complete all `n` courses. If it is impossible (due to cycles), indicate that it cannot be done. Describe an efficient algorithm for this and its time and space complexity. You may assume: - `1 <= n <= 10^5`. - `0 <= len(prerequisites) <= 2 * 10^5`. --- ### Problem 2: Analyze Dropped Requests Under a Rate Limiter You are running a social media website that suddenly went viral. To protect your backend, you added a rate limiter. Now you want to analyze logs to determine which requests would be dropped by this limiter. You are given: - An array `requests`, where the **index** is the request ID (0-based), and the **value** `requests[i]` is the time in seconds when the `i`-th request arrived. - The array `requests` is non-decreasing (requests are logged in arrival order; multiple requests can have the same timestamp if they arrive in the same second). Your rate limiter enforces the following rules: 1. At most **3 requests per second** can be processed. 2. At most **20 requests per any sliding 10-second window** can be processed. Formally: - For rule (1): For any timestamp `t`, among all requests with arrival time exactly `t`, at most 3 can be processed; any additional requests arriving at time `t` must be dropped. - For rule (2): For any request arriving at time `t`, consider all requests with arrival times in the interval `[t - 9, t]` (inclusive). If processing this request would cause the **total number of processed requests** in that interval to exceed 20, then this request must be dropped. Rules are applied in arrival order: - For each request in index order, first consider whether it is dropped due to rule (1) or rule (2), taking into account only previously processed requests (not the dropped ones). - If a request is dropped by **either** rule, it is not counted as processed for any future checks. #### Task Given the array `requests`, **return a list of the times of all dropped requests**, in the order they appear in the input. You should: - Clearly define the algorithm you use to determine dropped requests. - Aim for an efficient solution that can handle up to `10^5` requests. - State the time and space complexity of your approach. You may assume: - `1 <= len(requests) <= 10^5`. - `0 <= requests[i] <= 10^9`. - `requests` is non-decreasing.

Quick Answer: This combined question evaluates proficiency in graph-based dependency reasoning (cycle detection and course scheduling) and time-series request processing (rate-limiter behavior and sliding-window request counting) within the Coding & Algorithms domain.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
Snowflake logo
Snowflake
Nov 22, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0

You are given two independent coding problems.

Problem 1: Course Scheduling

You are planning to take a set of courses and are given prerequisite relationships between them.

  • There are n courses labeled from 0 to n - 1 .
  • You are given a list of prerequisite pairs prerequisites , where each pair [a, b] means you must complete course b before you can take course a .

Task A

Determine whether it is possible to finish all n courses.

  • Return true if you can complete all courses (i.e., the prerequisite graph has no cycle); otherwise return false .

You should specify the time and space complexity of your algorithm.

Task B (Follow-up)

Assume:

  • Each course takes exactly one semester to complete.
  • In any given semester, you may take any number of courses, as long as you have completed all of their prerequisites in earlier semesters.

If it is possible to finish all courses, compute the minimum number of semesters required to complete all n courses. If it is impossible (due to cycles), indicate that it cannot be done.

Describe an efficient algorithm for this and its time and space complexity.

You may assume:

  • 1 <= n <= 10^5 .
  • 0 <= len(prerequisites) <= 2 * 10^5 .

Problem 2: Analyze Dropped Requests Under a Rate Limiter

You are running a social media website that suddenly went viral. To protect your backend, you added a rate limiter. Now you want to analyze logs to determine which requests would be dropped by this limiter.

You are given:

  • An array requests , where the index is the request ID (0-based), and the value requests[i] is the time in seconds when the i -th request arrived.
  • The array requests is non-decreasing (requests are logged in arrival order; multiple requests can have the same timestamp if they arrive in the same second).

Your rate limiter enforces the following rules:

  1. At most 3 requests per second can be processed.
  2. At most 20 requests per any sliding 10-second window can be processed.

Formally:

  • For rule (1): For any timestamp t , among all requests with arrival time exactly t , at most 3 can be processed; any additional requests arriving at time t must be dropped.
  • For rule (2): For any request arriving at time t , consider all requests with arrival times in the interval [t - 9, t] (inclusive). If processing this request would cause the total number of processed requests in that interval to exceed 20, then this request must be dropped.

Rules are applied in arrival order:

  • For each request in index order, first consider whether it is dropped due to rule (1) or rule (2), taking into account only previously processed requests (not the dropped ones).
  • If a request is dropped by either rule, it is not counted as processed for any future checks.

Task

Given the array requests, return a list of the times of all dropped requests, in the order they appear in the input.

You should:

  • Clearly define the algorithm you use to determine dropped requests.
  • Aim for an efficient solution that can handle up to 10^5 requests.
  • State the time and space complexity of your approach.

You may assume:

  • 1 <= len(requests) <= 10^5 .
  • 0 <= requests[i] <= 10^9 .
  • requests is non-decreasing.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.