mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-05 01:36:32 +08:00
init
This commit is contained in:
28
else/topic/2020.h
Normal file
28
else/topic/2020.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "../structs/Tree.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TreeNode *getX(TreeNode *root, int x)
|
||||
{
|
||||
TreeNode *temp = root;
|
||||
while (temp)
|
||||
{
|
||||
if (temp->val > x)
|
||||
{
|
||||
if (temp->left)
|
||||
{
|
||||
temp = temp->left;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (temp->right)
|
||||
{
|
||||
temp = temp->right;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user