This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

60
else/topic/2019.h Normal file
View File

@@ -0,0 +1,60 @@
#include <vector>
using namespace std;
void odd_even(vector<int> &array)
{
int left = 0;
int right = array.size() - 1;
while (left < right)
{
while (left < right && array[right] % 2 == 0)
{
right--;
}
while (left < right && array[left] % 2 == 1)
{
left++;
}
swap(array[left], array[right]);
}
}
#include "../structs/Tree.h"
void insertSearchTree(TreeNode *root, int value)
{
TreeNode *dist = new TreeNode();
dist->val = value;
if (!root)
{
root = dist;
}
TreeNode *temp = root;
while (temp)
{
if (temp->val > value)
{
if (temp->left)
{
temp = temp->left;
continue;
}
temp->left = dist;
break;
}
if (temp->val < value)
{
if (temp->right)
{
temp = temp->right;
continue;
}
temp->left = dist;
break;
}
if (temp->val == value)
{
break;
}
}
}