Refactor structure
This commit is contained in:
parent
606185176c
commit
038fa42883
@ -1,13 +1,7 @@
|
||||
#ifndef S0002_ADD_TWO_NUMBERS_HPP
|
||||
#define S0002_ADD_TWO_NUMBERS_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0002 {
|
||||
public:
|
||||
|
@ -1,13 +1,7 @@
|
||||
#ifndef S0019_REMOVE_NTH_NODE_FROM_END_OF_LIST_HPP
|
||||
#define S0019_REMOVE_NTH_NODE_FROM_END_OF_LIST_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0019 {
|
||||
public:
|
||||
|
@ -3,15 +3,9 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
#include "structures.hpp"
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
using namespace std;
|
||||
|
||||
class S0021 {
|
||||
public:
|
||||
|
@ -3,15 +3,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
#include "structures.hpp"
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode *next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode *next) : val(x), next(next) {}
|
||||
};
|
||||
using namespace std;
|
||||
|
||||
class S0023 {
|
||||
public:
|
||||
|
@ -1,13 +1,7 @@
|
||||
#ifndef S0024_SWAP_NODES_IN_PAIRS_HPP
|
||||
#define S0024_SWAP_NODES_IN_PAIRS_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0024 {
|
||||
public:
|
||||
|
@ -4,15 +4,9 @@
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
#include "structures.hpp"
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
using namespace std;
|
||||
|
||||
class S0025 {
|
||||
public:
|
||||
|
@ -3,11 +3,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
struct IterResult {
|
||||
ListNode *node;
|
||||
@ -17,7 +13,7 @@ struct IterResult {
|
||||
class S0142 {
|
||||
public:
|
||||
std::unordered_map<ListNode *, int> footprint;
|
||||
IterResult iter(ListNode *fast, ListNode* slow, bool startUp);
|
||||
IterResult iter(ListNode *fast, ListNode *slow, bool startUp);
|
||||
ListNode *detectCycle(ListNode *head);
|
||||
};
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
#ifndef S0160_INTERSECTION_OF_TWO_LINKED_LISTS_HPP
|
||||
#define S0160_INTERSECTION_OF_TWO_LINKED_LISTS_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode *next;
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0160 {
|
||||
public:
|
||||
|
@ -1,13 +1,7 @@
|
||||
#ifndef S0203_REMOVE_LINKED_LIST_ELEMENTS_HPP
|
||||
#define S0203_REMOVE_LINKED_LIST_ELEMENTS_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0203 {
|
||||
public:
|
||||
|
@ -1,13 +1,7 @@
|
||||
#ifndef S0206_REVERSE_LINKED_LIST_HPP
|
||||
#define S0206_REVERSE_LINKED_LIST_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0206 {
|
||||
public:
|
||||
|
11
include/s0226_invert_binary_tree.hpp
Normal file
11
include/s0226_invert_binary_tree.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef S0226_INVERT_BINARY_TREE_HPP
|
||||
#define S0226_INVERT_BINARY_TREE_HPP
|
||||
|
||||
#include "structures.hpp"
|
||||
|
||||
class S0226 {
|
||||
public:
|
||||
TreeNode* invertTree(TreeNode* root);
|
||||
};
|
||||
|
||||
#endif
|
22
include/structures.hpp
Normal file
22
include/structures.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef STRUCTURES_HPP
|
||||
#define STRUCTURES_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode *next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode *next) : val(x), next(next) {}
|
||||
};
|
||||
|
||||
struct TreeNode {
|
||||
int val;
|
||||
TreeNode *left;
|
||||
TreeNode *right;
|
||||
TreeNode() : val(0), left(nullptr), right(nullptr) {}
|
||||
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
|
||||
TreeNode(int x, TreeNode *left, TreeNode *right)
|
||||
: val(x), left(left), right(right) {}
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user