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

16
23/09/2594.h Normal file
View File

@@ -0,0 +1,16 @@
//
// Created by 李洋 on 2023/9/7.
//
#ifndef LEECODE_C_2594_H
#define LEECODE_C_2594_H
#include <vector>
using namespace std;
long long repairCars(vector<int> &ranks, int cars) {
}
#endif //LEECODE_C_2594_H

34
23/09/Q1123.h Normal file
View File

@@ -0,0 +1,34 @@
//
// Created by 李洋 on 2023/9/6.
//
#ifndef LEECODE_C_Q1123_H
#define LEECODE_C_Q1123_H
#pragma once
#include "../../dataStruct/Tree/TreeStack.h"
std::pair<TreeNode *, int> f(TreeNode *root) {
if (!root) {
return {root, 0};
}
auto left = f(root->left);
auto right = f(root->right);
if (left.second > right.second) {
return {left.first, left.second + 1};
}
if (left.second < right.second) {
return {right.first, right.second + 1};
}
return {root, left.second + 1};
}
struct TreeNode *lcaDeepestLeaves(struct TreeNode *root) {
return f(root).first;
}
#endif //LEECODE_C_Q1123_H

21
23/09/Q2240.h Normal file
View File

@@ -0,0 +1,21 @@
//
// Created by 李洋 on 2023/9/1.
//
#ifndef LEECODE_C_2240_H
#define LEECODE_C_2240_H
class Q2240 {
public:
long long waysToBuyPensPencils(int total, int cost1, int cost2) {
long long count = total / cost2 + 1;
int tos = total / cost1;
for (int i = 1; i <= tos; ++i) {
int temp = total - i * cost1;
count += temp / cost2 + 1;
}
return count;
}
};
#endif //LEECODE_C_2240_H