Available question text
Given an undirected graph (allowing multiple edges), for each query q count pairs of nodes (a,b) with incident(a,b) = deg[a] + deg[b] − commonEdges(a,b) > q. The challenge is to do this faster than O(n^2) by using sorted degrees (two-pointer counting) and correcting counts for pairs that share edges, since n and |edges| can be large.
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 1782. Count Pairs Of Nodes
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source