Skip to content

Commit a1bcbf5

Browse files
author
Kun Luo
committed
.
1 parent 416ec09 commit a1bcbf5

File tree

67 files changed

+123
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+123
-123
lines changed

src/4sum.cc 4sum.cc

File renamed without changes.

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
66

77
message( ${CMAKE_CURRENT_SOURCE_DIR})
88

9-
file(GLOB main_files LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
9+
file(GLOB main_files LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc)
1010
foreach(main_file IN LISTS main_files)
1111
cmake_path(GET main_file STEM main_name)
1212
add_executable(${main_name} ${main_file})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/gray-code.cc gray-code.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/leetcode.h leetcode.h

+122-122
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,123 @@
1-
#pragma once
2-
3-
#include <algorithm>
4-
#include <array>
5-
#include <bitset>
6-
#include <cassert>
7-
#include <chrono>
8-
#include <deque>
9-
#include <fstream>
10-
#include <functional>
11-
#include <iomanip>
12-
#include <iostream>
13-
#include <iterator>
14-
#include <list>
15-
#include <map>
16-
#include <memory>
17-
#include <numeric>
18-
#include <ostream>
19-
#include <queue>
20-
#include <random>
21-
#include <set>
22-
#include <sstream>
23-
#include <stack>
24-
#include <string>
25-
#include <utility>
26-
#include <vector>
27-
28-
struct ListNode {
29-
int value = 0;
30-
ListNode *next = nullptr;
31-
explicit ListNode(int val) : value(val) {}
32-
};
33-
34-
struct TreeNode {
35-
int value = 0;
36-
TreeNode *left = nullptr;
37-
TreeNode *right = nullptr;
38-
};
39-
40-
namespace utils {
41-
42-
template <typename Fn> void foreach (ListNode *n, Fn && fn) {
43-
while (n != nullptr) {
44-
fn(n->value);
45-
n = n->next;
46-
}
47-
}
48-
49-
template <typename T = int, typename TIterable = std::initializer_list<T>> ListNode *make_nodes(TIterable &&iterable) {
50-
auto end = std::end(iterable);
51-
auto iter = std::begin(iterable);
52-
if (iter == end) { return nullptr; }
53-
auto *head = new ListNode(*iter++);
54-
for (ListNode *p = head; iter != end; ++iter, p = p->next) { p->next = new ListNode(static_cast<int>(*iter)); }
55-
return head;
56-
}
57-
58-
inline void del_nodes(ListNode *n) {
59-
for (ListNode *next; n != nullptr; n = next) {
60-
next = n->next;
61-
delete n;
62-
}
63-
}
64-
65-
inline void print_nodes(ListNode *n) {
66-
if (n == nullptr) {
67-
std::cout << "[]" << std::endl;
68-
return;
69-
}
70-
while (n->next != nullptr) {
71-
std::cout << "[" << n->value << "] -> ";
72-
n = n->next;
73-
}
74-
std::cout << "[" << n->value << "]" << std::endl;
75-
}
76-
77-
inline TreeNode *make_tree(const int v, TreeNode *ln = nullptr, TreeNode *rn = nullptr) {
78-
return new TreeNode{v, ln, rn};
79-
}
80-
81-
inline void del_tree(TreeNode *n) {
82-
if (n == nullptr) { return; }
83-
del_tree(n->left);
84-
del_tree(n->right);
85-
delete n;
86-
}
87-
88-
template <typename TIterable> void print(TIterable &&iterable) {
89-
auto end = std::end(iterable);
90-
auto iter = std::begin(iterable);
91-
std::cout << "[";
92-
if (iter != end) {
93-
std::cout << *iter;
94-
++iter;
95-
}
96-
while (iter != end) {
97-
std::cout << ", " << *iter;
98-
++iter;
99-
}
100-
std::cout << "]";
101-
}
102-
103-
inline void print(std::ostream &out, const int it) {
104-
out << std::setw(4) << it;
105-
}
106-
107-
inline void print(std::ostream &out, const bool it) {
108-
out << std::setw(4) << (it ? "O" : "X");
109-
}
110-
111-
template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &vec) {
112-
print(vec);
113-
return out;
114-
}
115-
116-
template <typename T> void operator<<(std::ostream &out, const std::vector<std::vector<T>> &mat) {
117-
for (auto &&vec : mat) {
118-
for (auto &&v : vec) { print(out, v); }
119-
out << std::endl;
120-
}
121-
}
122-
1+
#pragma once
2+
3+
#include <algorithm>
4+
#include <array>
5+
#include <bitset>
6+
#include <cassert>
7+
#include <chrono>
8+
#include <deque>
9+
#include <fstream>
10+
#include <functional>
11+
#include <iomanip>
12+
#include <iostream>
13+
#include <iterator>
14+
#include <list>
15+
#include <map>
16+
#include <memory>
17+
#include <numeric>
18+
#include <ostream>
19+
#include <queue>
20+
#include <random>
21+
#include <set>
22+
#include <sstream>
23+
#include <stack>
24+
#include <string>
25+
#include <utility>
26+
#include <vector>
27+
28+
struct ListNode {
29+
int value = 0;
30+
ListNode *next = nullptr;
31+
explicit ListNode(int val) : value(val) {}
32+
};
33+
34+
struct TreeNode {
35+
int value = 0;
36+
TreeNode *left = nullptr;
37+
TreeNode *right = nullptr;
38+
};
39+
40+
namespace utils {
41+
42+
template <typename Fn> void foreach (ListNode *n, Fn && fn) {
43+
while (n != nullptr) {
44+
fn(n->value);
45+
n = n->next;
46+
}
47+
}
48+
49+
template <typename T = int, typename TIterable = std::initializer_list<T>> ListNode *make_nodes(TIterable &&iterable) {
50+
auto end = std::end(iterable);
51+
auto iter = std::begin(iterable);
52+
if (iter == end) { return nullptr; }
53+
auto *head = new ListNode(*iter++);
54+
for (ListNode *p = head; iter != end; ++iter, p = p->next) { p->next = new ListNode(static_cast<int>(*iter)); }
55+
return head;
56+
}
57+
58+
inline void del_nodes(ListNode *n) {
59+
for (ListNode *next; n != nullptr; n = next) {
60+
next = n->next;
61+
delete n;
62+
}
63+
}
64+
65+
inline void print_nodes(ListNode *n) {
66+
if (n == nullptr) {
67+
std::cout << "[]" << std::endl;
68+
return;
69+
}
70+
while (n->next != nullptr) {
71+
std::cout << "[" << n->value << "] -> ";
72+
n = n->next;
73+
}
74+
std::cout << "[" << n->value << "]" << std::endl;
75+
}
76+
77+
inline TreeNode *make_tree(const int v, TreeNode *ln = nullptr, TreeNode *rn = nullptr) {
78+
return new TreeNode{v, ln, rn};
79+
}
80+
81+
inline void del_tree(TreeNode *n) {
82+
if (n == nullptr) { return; }
83+
del_tree(n->left);
84+
del_tree(n->right);
85+
delete n;
86+
}
87+
88+
template <typename TIterable> void print(TIterable &&iterable) {
89+
auto end = std::end(iterable);
90+
auto iter = std::begin(iterable);
91+
std::cout << "[";
92+
if (iter != end) {
93+
std::cout << *iter;
94+
++iter;
95+
}
96+
while (iter != end) {
97+
std::cout << ", " << *iter;
98+
++iter;
99+
}
100+
std::cout << "]";
101+
}
102+
103+
inline void print(std::ostream &out, const int it) {
104+
out << std::setw(4) << it;
105+
}
106+
107+
inline void print(std::ostream &out, const bool it) {
108+
out << std::setw(4) << (it ? "O" : "X");
109+
}
110+
111+
template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &vec) {
112+
print(vec);
113+
return out;
114+
}
115+
116+
template <typename T> void operator<<(std::ostream &out, const std::vector<std::vector<T>> &mat) {
117+
for (auto &&vec : mat) {
118+
for (auto &&v : vec) { print(out, v); }
119+
out << std::endl;
120+
}
121+
}
122+
123123
} // namespace utils
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/maximum-gap.cc maximum-gap.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/n-queens-ii.cc n-queens-ii.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/rotate-list.cc rotate-list.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/subsets.cc subsets.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/two-sum.cc two-sum.cc

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/xun-bao.cc xun-bao.cc

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)