← All problemsSign in

Is it a tree

You are given an unweighted, undirected graph. Write a program to check if it's a tree topology. Input The first line of the input file contains two integers N and M --- number of nodes and number of edges in the graph (0 Output Print YES if the given graph is a tree, otherwise print NO. Example Input: 3 2 1 2 2 3 Output: YES

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start