If you always declare global variable instead of local,
Once you using recursive call, you may get run time error.
See
Once you using recursive call, you may get run time error.
See
SPOJ Problem 1436: Is it a tree – PT07Y
if you move
list<int>::iterator it;
from local variable to global variable, you will get run time error
by input following:
3 2
1 3
3 2