How Many Paths of Length K Are There Between a and B? (2021)
Posted4 months agoActive4 months ago
horace.ioTechstory
calmmixed
Debate
40/100
Graph TheoryAlgorithmsDynamic Programming
Key topics
Graph Theory
Algorithms
Dynamic Programming
The post discusses methods to count the number of paths of length K between two nodes in a graph, sparking a discussion on the most efficient approaches and the application of various mathematical concepts.
Snapshot generated from the HN discussion
Discussion Activity
Light discussionFirst comment
5h
Peak period
3
14-16h
Avg / period
1.7
Comment distribution12 data points
Loading chart...
Based on 12 loaded comments
Key moments
- 01Story posted
Aug 24, 2025 at 4:09 PM EDT
4 months ago
Step 01 - 02First comment
Aug 24, 2025 at 9:27 PM EDT
5h after posting
Step 02 - 03Peak activity
3 comments in 14-16h
Hottest window of the conversation
Step 03 - 04Latest activity
Aug 25, 2025 at 4:08 PM EDT
4 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45007333Type: storyLast synced: 11/20/2025, 6:48:47 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
> queue = [(A, 0)] # We track (length of walk, current node)
Surely the comment should be reversed, right?
Also, how are we encoding “current node”? Is it an integer? Does A=0, and the rest of the nodes have some arbitrary value? How do we calculate `neighbors(node)`?
> Also, how are we encoding “current node”? Is it an integer? Does A=0, and the rest of the nodes have some arbitrary value? How do we calculate `neighbors(node)`?
This is the "discussion" part of the interview where you're supposed to ask, and the interviewer will tell you that you can assume the nodes are numbered from 0/1 to N-1/N. I imagine the adjacency modeling is up to you since you'll be judged based off what representation you pick, and that will depend on the proposed solution.
Or tool up and get a better programming language?
I wish I hadn't read the fourth solution description -- the language used wasn't clear at all to me, but it was enough to point me in the right direction, or maybe I'm just that clever?
That said, I don't like interview questions like that -- there's very much a component of you either get it or you don't. The interviewer says they talk people through it, and if they're good at that, great. But if not, a question like that is (in my book) unfair.