Find Node with Maximum Common Neighbors, Not Directly Connected
Problem: Given an undirected graph with nodes 0 to n-1, for each node find another node such that: (a) they are not directly connected, and (b) they have the maximum number of common neighbors. If there are multiple such nodes, choose the one with the smallest index.
Constraints: n < 10^5, each node has at most 15 neighbors.
Approach: Since each node has at most 15 neighbors, for each node u, iterate over its neighbors' neighbors (2-hop candidates) — at most 15*15 = 225 candidates — count how many of u's neighbors each candidate v shares (using a hashset intersection or bitset for u's neighbor set), skip candidates directly connected to u, and track the best (max common neighbors, smallest index) candidate. Overall O(n * 225) which is efficient given the degree bound.