int main(){
	Solution c;
	TreeNode *root = new TreeNode(3);
	root->left = new TreeNode(5);
	root->right = new TreeNode(1);
	root->left->left = new TreeNode(6);
	root->left->right = new TreeNode(2);
	root->right->left = new TreeNode(0);
	root->right->right = new TreeNode(8);
	root->left->right->left = new TreeNode(7);
	root->left->right->right = new TreeNode(4);
	TreeNode *p = root->left, *q = root->left->right->right;
	cout << p->val << " " << q->val << endl;
	TreeNode *s = c.LCA(root,p,q);//c.lowestCommonAncestor(root, p, q);
	cout << s->val;
	return 0;
}
int main(int argc, char** argv){
  Solution S;
  
  int* arr = (int *)malloc(sizeof(int)* (argc -1));
  for(int i = 1; i < argc; i ++){
     arr[i-1] = atoi(argv[i]);
  }
  
  //int arr [] = { 12 ,123, 12312, 42112, 13421, 1234,312, 314};
  //int n = sizeof(arr)/sizeof(int);
 
  TreeNode * root = S.sortedArrToBST(arr, argc -1);
  S.print(root);

  cout<<"isBST? "<<S.isBST(root)<<endl;
  //cout<<"Maximum number of the BST: "<<S.maxNum(root)<<endl;

  cout<<"Get the maximum number for the left subtree of the root: "<<S.getMax(root->left)<<endl;

  cout<<"Get the maximum number of the BST: "<<S.getMax(root)<<endl;

  cout<<"Verify the BST: "<<S.verify(root)<<endl;
  
  

  cout<<"The second maximum number of the BST: "<<S.getSecondMax(root)<<endl;

  cout<<"Print type in two nums in the BST: "<<endl;
  
  int n1, n2;
  cin>>n1>>n2;
  
  TreeNode * ans = S.LCA(root, n1, n2);
  cout<<"You are typing in : "<<n1<<" "<<n2<<endl;
  if(ans == NULL)
    cout<<"No lowest common ancestor for those two nodes !"<<endl;
  else
    cout<<"Lowest common ancestor for those two nodes is: "<<ans->val<<endl;
  
  cout<<"Printing the maximum num for each path from root to leaf: "<<endl;
  S.printMaximumOnPath(root, INT_MIN);
  free(arr);
  return 0;

}