For this Question: Given a binary tree with root 1. You have to make some other node as the root such that all conditions of a binary tree is satisfied. Print all nodes other than 1 that can be made as the root of the tree in sorted order.
Note - You cannot add/remove a node. You cannot break any edge.First line contains the integer N, denoting the number of nodes in the binary tree.
Next N lines contains two integers denoting the left and right child of the i'th node respectively. 
If the node doesn't have a left or right child, it is denoted by '-1'

1 <= N <= 100000Print in a single line all nodes other than 1 that can be made as the root. You must print in increasing order.Sample Input 1:
5
2 4
5 -1
-1 -1
-1 3
-1 -1
Sample output 1:
2 3 4 5

Explanation: Given binary tree 
                1
               /  \
             2     4
            /        \
          5           3
One possible configuration of tree when 4 is made as the root
                4
               /  \
             1     3
            /      
           2 
         / 
        5  , I have written this Solution Code: #include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int d[N];

void solve(){
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		int x, y;
		cin >> x >> y;
		if(x != -1)	d[i]++, d[x]++;
		if(y != -1)	d[i]++, d[y]++;
	}
	for(int i = 2; i <= n; i++){
		if(d[i] <= 2)
			cout << i << " ";
	}
}

signed main() {
	IOS;
		clock_t start = clock();
	
	int Test = 1;	
	// cin >> Test;
	for(int tt = 0; tt < Test; tt++){


		solve();
	}

	cerr << (double)(clock() - start)*1000/CLOCKS_PER_SEC << " ms" << endl;
	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?