全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

description:sync gists with given description

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

all:systemctl search all fields

註冊

登錄

全部 新建 註冊 登錄

linkjobai

加入 5 days ago

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新
所有 Gists 1

linkjobai / Topological Sort in Coding Interviews: Kahn's Algorithm Explained

0 喜歡
0 分支
1 檔案
最後活躍 5 days ago
Interview prep notes
interview

Topological Sort in Coding Interviews: Kahn's Algorithm Explained

Problems like Course Schedule (LeetCode 207/210), Alien Dictionary and build-order questions are all the same idea: you have tasks with "must happen before" rules, and you need a valid order (or proof that none exists).

The idea in one sentence

Repeatedly take a node with no remaining prerequisites (in-degree 0), output it, and remove its outgoing edges.

Python template (Kahn's algorithm)

上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 35ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文