There are some codes (including C/C++, Java, Python, ...) for algorithm, such as the solutions for leetcode
The .hpp file is name with the name of the question, whose spaces are replaced by '_'.
Moreover, And your username is added to the end of the file name
such as:
For the question "1. Two Sum"
The .hpp file is: "1_Two_Sum_username.hpp"
The .hpp file adds "#include "../base/icode.hpp" " in the first line.
The clase name in .hpp file is named to 'L' + the id of the question, and inherits the class "icode".
The run method is overrided in the class.
such as:
#include "../base/icode.hpp"
class L1 : public icode {
...
void run() {
...
}
};
The main file is main.cpp, where you can execute your solution.
In the leetcode directory, create a file and name it as the problem name, such as '1. Two Sum'.
Then run script.py to change the file name.
python .\script.py
Finally, run script.py to create Factory.hpp.
python .\script.py make
When you wanna run a question, run icode.cpp and input the id of this question. When you input the id <=0, the program ends.
./build/main.exe
78
1
2
1 2
3
1 3
2 3
1 2 3
-1
This question is not existed!