Search
⌘K

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.

Comments

Your account is free and you can post anonymously if you choose.