PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Coding & Algorithms/Snowflake

Compute task order with prerequisites

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in graph algorithms—particularly topological ordering and cycle detection—along with the use of efficient data structures for representing dependencies and analyzing time and space complexity.

  • Medium
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Compute task order with prerequisites

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given an integer n representing tasks labeled 0..n-1 and a list of prerequisite pairs (a, b) meaning b must be completed before a, return any valid ordering of tasks that completes all tasks, or an empty list if no ordering exists. Design an efficient algorithm and data structures, explain how you detect cycles, and analyze time and space complexity. Follow-ups: ( 1) How would you produce all tasks that are part of at least one cycle? ( 2) How would you handle up to 100,000 tasks and 200,000 prerequisites?

Quick Answer: This question evaluates proficiency in graph algorithms—particularly topological ordering and cycle detection—along with the use of efficient data structures for representing dependencies and analyzing time and space complexity.

Related Interview Questions

  • 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)
  • Minimize coins with overpay and change - Snowflake (hard)
Snowflake logo
Snowflake
Aug 14, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0

Given an integer n representing tasks labeled 0..n-1 and a list of prerequisite pairs (a, b) meaning b must be completed before a, return any valid ordering of tasks that completes all tasks, or an empty list if no ordering exists. Design an efficient algorithm and data structures, explain how you detect cycles, and analyze time and space complexity. Follow-ups: (

  1. How would you produce all tasks that are part of at least one cycle? (
  2. How would you handle up to 100,000 tasks and 200,000 prerequisites?

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
  • Careers
  • 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.