Skip to content

Instantly share code, notes, and snippets.

@tuanchauict
Created October 19, 2025 08:08
Show Gist options
  • Select an option

  • Save tuanchauict/6d466a3b8306c0a71039455468b21906 to your computer and use it in GitHub Desktop.

Select an option

Save tuanchauict/6d466a3b8306c0a71039455468b21906 to your computer and use it in GitHub Desktop.
FAANG Topological Sort Problem Collection

πŸ“š FAANG Topological Sort Problem Collection

Here's a curated list of topological sort problems frequently asked by FAANG companies, organized by difficulty and problem pattern.


🟒 Foundation Level (Must Master)

1. Course Schedule

Link: https://leetcode.com/problems/course-schedule/
Difficulty: Medium
Why FAANG Loves It: Classic cycle detection in directed graph - tests understanding of topological sort prerequisites
Companies: Amazon, Meta, Google, Microsoft

2. Course Schedule II

Link: https://leetcode.com/problems/course-schedule-ii/
Difficulty: Medium
Why FAANG Loves It: Extends Course Schedule - must actually return the topological order
Companies: Amazon, Meta, Google, Microsoft, Apple


🟑 Intermediate Level (Common Interview Questions)

3. Minimum Height Trees

Link: https://leetcode.com/problems/minimum-height-trees/
Difficulty: Medium
Why FAANG Loves It: Tests topological sort on undirected graphs + creative thinking
Companies: Google, Meta, Amazon

4. Alien Dictionary

Link: https://leetcode.com/problems/alien-dictionary/ πŸ”’
Difficulty: Hard
Why FAANG Loves It: EXTREMELY POPULAR - combines graph construction + topological sort + edge case handling
Companies: Google (favorite), Meta, Amazon, Microsoft, Apple

5. Sequence Reconstruction

Link: https://leetcode.com/problems/sequence-reconstruction/ πŸ”’
Difficulty: Medium
Why FAANG Loves It: Tests understanding of unique topological ordering
Companies: Google, Amazon

6. Course Schedule III

Link: https://leetcode.com/problems/course-schedule-iii/
Difficulty: Hard
Why FAANG Loves It: Combines greedy + topological thinking (though more greedy-focused)
Companies: Google, Meta

7. Parallel Courses

Link: https://leetcode.com/problems/parallel-courses/ πŸ”’
Difficulty: Medium
Why FAANG Loves It: Tests BFS-based topological sort with level tracking
Companies: Amazon, Google


πŸ”΄ Advanced Level (Senior Engineer / Harder Rounds)

8. Parallel Courses II

Link: https://leetcode.com/problems/parallel-courses-ii/ πŸ”’
Difficulty: Hard
Why FAANG Loves It: Topological sort + dynamic programming/bitmask - very challenging
Companies: Google, Meta

9. Sort Items by Groups Respecting Dependencies

Link: https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies/
Difficulty: Hard
Why FAANG Loves It: Multi-level topological sort - separates senior candidates from others
Companies: Google, Amazon, Meta

10. Build a Matrix With Conditions

Link: https://leetcode.com/problems/build-a-matrix-with-conditions/
Difficulty: Hard
Why FAANG Loves It: 2D topological sort - tests deep understanding
Companies: Google, Amazon


🎯 Variant Problems (Tests Pattern Recognition)

11. Find All Possible Recipes from Given Supplies

Link: https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/
Difficulty: Medium
Why FAANG Loves It: Disguised topological sort - tests pattern recognition
Companies: Amazon, Microsoft

12. Loud and Rich

Link: https://leetcode.com/problems/loud-and-rich/
Difficulty: Medium
Why FAANG Loves It: DFS/topological sort with memoization
Companies: Meta, Google

13. Strange Printer II

Link: https://leetcode.com/problems/strange-printer-ii/
Difficulty: Hard
Why FAANG Loves It: Non-obvious topological sort application
Companies: Google


πŸ’‘ Practice Strategy

Week 1-2: Foundation

  • Master Course Schedule I & II
  • Understand both BFS (Kahn's) and DFS approaches
  • Practice explaining your approach out loud

Week 3-4: Pattern Recognition

  • Alien Dictionary - practice 5+ times until fluent
  • Parallel Courses - master level-by-level processing
  • Minimum Height Trees - understand the "peeling" technique

Week 5+: Advanced Applications

  • Sort Items by Groups - this will prepare you for anything
  • Build a Matrix With Conditions - dual topological sort mastery
  • Practice disguised problems to sharpen pattern recognition

πŸš€ Key Techniques to Master

  1. Cycle Detection (DFS with color marking)
  2. Kahn's Algorithm (BFS with in-degree counting)
  3. Multi-level Topological Sort (nested graph dependencies)
  4. Unique vs Multiple Valid Orders (checking uniqueness)
  5. Level-by-level Processing (parallel execution simulation)

πŸ“Š Company Frequency Guide

πŸ”₯ Hot Topics:

  • Google: Alien Dictionary, Sort Items by Groups, Multi-level sorts
  • Amazon: Course Schedule variations, Parallel Courses, Recipe problems
  • Meta: Alien Dictionary, Minimum Height Trees, Loud and Rich
  • Microsoft: Course Schedule, Find All Recipes, Basic to Medium problems

Ready to tackle one? Pick a problem and let me know - I'll guide you through with hints! 🎯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment