This Hard difficulty Add Edges coding problem involves a graph where some nodes have an "odd degree" (an odd number of connected edges). You are allowed to add at most two new edges to the graph such that every node in the final graph has an even degree. You must determine if this is possible given the existing edges.
Uber and Quant firms ask this to test graph theory fundamentals. It requires understanding that in any graph, the number of odd-degree nodes is always even. By restricting the number of new edges to two, the problem becomes a case-study in combinatorial logic.
This utilizes the Graph and Hash Table interview pattern.
Suppose nodes 1, 2, 3, and 4 are the only odd-degree nodes.
Always count the degrees of nodes first in graph problems. Parity (even vs. odd) is a frequent theme in advanced graph challenges.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Node With Highest Edge Score | Medium | Solve | |
| String Transforms Into Another String | Hard | Solve | |
| Find the Town Judge | Easy | Solve | |
| Clone Graph | Medium | Solve | |
| Find Champion II | Medium | Solve |