Ai
1 Star 1 Fork 0

hangq/coder

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
solution.h 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
hangq 提交于 2023-08-29 17:05 +08:00 . rearch question testcase solution
/*
* Created by hangangqiang on 2023.08.29.
*/
#ifndef LEETCODE_SOLUTION_H
#define LEETCODE_SOLUTION_H
#include <memory>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "data.h"
#include "test_case.h"
class Solution {
public:
explicit Solution(std::string name = "") : name_(std::move(name)){};
void SetName(const std::string &name) { this->name_ = name; }
std::string GetName() const { return this->name_; }
virtual std::unique_ptr<Data> Execute(std::unique_ptr<TestCase> &test_case) {
if (test_case == nullptr) {
return nullptr;
}
return Solve(*test_case->GetInput());
}
protected:
virtual std::unique_ptr<Data> Solve(Data &input) = 0;
std::string name_;
};
#define DefSolution(name) \
class Solution##name : public Solution { \
public: \
explicit Solution##name() = default; \
\
protected: \
std::unique_ptr<Data> Solve(Data &input) override; \
}
#endif // LEETCODE_SOLUTION_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hangangqiang/coder.git
git@gitee.com:hangangqiang/coder.git
hangangqiang
coder
coder
master

搜索帮助