In the solution, we iterate through both the edges and nodes separately. Shouldn’t the time complexity be O(n + m) where n is number the nodes and m is the number of edges? Or does it get adjusted to just O(n) because we know the number of edges is approximately the same as the number of nodes?

Course: Grokking Coding Interview Patterns in JavaScript - Learn Interactively

Lesson: Solution: Graph Valid Tree