Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1782. Count Pairs Of Nodes
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.