Available question text
Count, for each k, the number of ordered pairs of nodes in a path graph of n houses with one extra shortcut edge (x,y) whose shortest-path distance equals k. The challenge is to efficiently tally pairs for every k by comparing the direct distance |i−j| with distances that go through the shortcut, avoiding O(n^2) pairwise checks.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3017. Count the Number of Houses at a Certain Distance II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source