problemscpp
A collection of my answers to algorithm problems in c++.
lintcode.h
浏览该文件的文档.
1#ifndef PROBLEMSCPP_LINTCODE_H
2#define PROBLEMSCPP_LINTCODE_H
3
4#include <string>
5#include <vector>
6
7using namespace std;
8
9namespace lintcode {
10 class TreeNode {
11 public:
12 int val;
14
15 explicit TreeNode(int val)
16 : val(val), left(nullptr), right(nullptr){};
17 };
18
19 namespace license_key_formatting {
20 class Solution {
21 public:
27 static string licenseKeyFormatting(string & /*S*/, int /*K*/);
28 };
29 }// namespace license_key_formatting
30
31 namespace distribute_candies {
32 class Solution {
33 public:
38 static int distributeCandies(vector<int> &candies);
39 };
40 }// namespace distribute_candies
41
42 namespace remove_extra {
43 class Solution {
44 public:
49 static string removeExtra(string &s);
50 };
51 }// namespace remove_extra
52
56 namespace character_deletion {
57 class Solution {
58 public:
64 static string CharacterDeletion(string &str, string &sub);
65 };
66 }// namespace character_deletion
67
71 namespace judge_circle {
72 class Solution {
73 public:
78 static bool judgeCircle(string &moves);
79 };
80 }// namespace judge_circle
81
85 namespace intersection {
86 class Solution {
87 public:
93 static vector<vector<int>> Intersection(vector<vector<int>> &a, vector<vector<int>> &b);
94
95 static bool is_intersected(const vector<int> &l, const vector<int> &r);
96 };
97 }// namespace intersection
98
100 namespace flatten {
101 class Solution {
102 public:
107 static void flatten(TreeNode *root);
108
109 static TreeNode *vlr(TreeNode * /*node*/);
110 };
111 }// namespace flatten
112
116 namespace convert {
117 class Solution {
118 public:
123 static string convert(long long index);
124 };
125 }// namespace convert
126
128 namespace min_path_sum {
129 class Solution {
130 public:
135 static int minPathSum(vector<vector<int>> &grid);
136 };
137 }// namespace min_path_sum
138
140 namespace digit_counts {
141 class Solution {
142 public:
148 static int digitCounts(int k, int n);
149 };
150 }// namespace digit_counts
151
156 namespace min_diff_in_BST {
157 class Solution {
158 public:
163 static int minDiffInBST(TreeNode *root);
164 };
165 }// namespace min_diff_in_BST
166}// namespace lintcode
167
168#endif//PROBLEMSCPP_LINTCODE_H
vector< int > root
Definition: acwing408.cpp:349
TreeNode * right
Definition: lintcode.h:13
TreeNode * left
Definition: lintcode.h:13
TreeNode(int val)
Definition: lintcode.h:15
static string licenseKeyFormatting(string &, int)
Definition: lintcode.cpp:18
static int distributeCandies(vector< int > &candies)
Definition: lintcode.cpp:56
static string removeExtra(string &s)
Definition: lintcode.cpp:86
static string CharacterDeletion(string &str, string &sub)
Definition: lintcode.cpp:107
static bool judgeCircle(string &moves)
Definition: lintcode.cpp:123
static vector< vector< int > > Intersection(vector< vector< int > > &a, vector< vector< int > > &b)
Definition: lintcode.cpp:148
static bool is_intersected(const vector< int > &l, const vector< int > &r)
Definition: lintcode.cpp:169
static TreeNode * vlr(TreeNode *)
Definition: lintcode.cpp:188
static void flatten(TreeNode *root)
Definition: lintcode.cpp:181
static string convert(long long index)
Definition: lintcode.cpp:213
static int minPathSum(vector< vector< int > > &grid)
Definition: lintcode.cpp:248
static int digitCounts(int k, int n)
Definition: lintcode.cpp:279
static int minDiffInBST(TreeNode *root)
Definition: lintcode.cpp:298