Empresa engajada
You are given a binary tree as input , find whether the tree is a BST or not .
Sigiloso
Take the inorder traversal of the tree . If its a sorted list , its bst .
bool isBST(Node* root) { if (root == NULL) return true; bool lbst = true; bool rbst = true; if (root->left) { if(root->left->val val) return false; lbst = isBST(root->left); } if (lbst && root->right) { if (root->right->val > root->val) return false; rbst = isBST(root->right); } return rbst && lbst;
Fique por dentro de todas as oportunidades e dicas internas seguindo as empresas de seus sonhos.
Comece a buscar vagas para receber atualizações e recomendações personalizadas.