C # program to construct a tree using inorder and preorder traversal
using System ; using System . Collections . Generic ; public class TreeNode { public int val ; public TreeNode left ; public TreeNode right ; public TreeNode ( int x ) { val = x ; } } class GFG { static HashSet < TreeNode > set = new HashSet < TreeNode > ( ) ; static Stack < TreeNode > stack = new Stack < TreeNode > ( ) ;