I know the brute force approach for solving this problem which can be given as:
- Iterate over all edges
- Take a set(or list)(suppose s)
- if adding an edge to s doesn't make a cycle then add edge to s
- End if iteration is complete over all edges.
But I want an efficient solution(time+space both) for this problem.
So, Any help will be appreciated...........