Todos Novo

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Registrar-se

Entrar

Todos Novo Registrar-se Entrar

All gists matching topic interview

Mais recente criado
Menos recente criado
Mais recente atualizado
Menos recente atualizado

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

0 curtidas
0 bifurcações
1 arquivos
Última atividade 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)

Próximo Anterior

Desenvolvido por Opengist ⋅ Load: 35ms⋅

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