leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0998.cpp (414B)


0 class Solution { 1 public: 2 TreeNode *insertIntoMaxTree(TreeNode *root, int val) { 3 TreeNode *node = new TreeNode(val), *cur = root; 4 if (root->val < val) { 5 node->left = root; 6 return node; 7 } 8 9 while (cur->right && cur->right->val > val) 10 cur = cur->right; 11 12 node->left = cur->right; 13 cur->right = node; 14 return root; 15 } 16 };