Skip to content

Commit 2412bc5

Browse files
committed
changed name
1 parent 56ff884 commit 2412bc5

File tree

301 files changed

+1226
-1226
lines changed

Some content is hidden

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

301 files changed

+1226
-1226
lines changed
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include <iostream>
2-
#include "solution.h"
3-
4-
// Unit Test
5-
6-
int main()
7-
{
8-
Solution s;
9-
int A[7] = {1,2,3,5,2,1,3};
10-
std::cout << s.singleNumber(A, 7) << std::endl;
11-
12-
return 0;
13-
}
1+
#include <iostream>
2+
#include "solution.h"
3+
4+
// Unit Test
5+
6+
int main()
7+
{
8+
Solution s;
9+
int A[7] = {1,2,3,5,2,1,3};
10+
std::cout << s.singleNumber(A, 7) << std::endl;
11+
12+
return 0;
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class Solution {
2-
public:
3-
int singleNumber(int A[], int n) {
4-
int r{0};
5-
for (int i = 0; i != n; ++i)
6-
r ^= A[i];
7-
return r;
8-
}
9-
};
1+
class Solution {
2+
public:
3+
int singleNumber(int A[], int n) {
4+
int r{0};
5+
for (int i = 0; i != n; ++i)
6+
r ^= A[i];
7+
return r;
8+
}
9+
};
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
#include <iostream>
2-
#include "solution.h"
3-
4-
// Test Unit
5-
// Create a tree for test
6-
// 1
7-
// / \
8-
// 2 3
9-
// / \ \
10-
// 4 5 6
11-
// / \
12-
// 7 8
13-
// /
14-
// 9
15-
16-
17-
int main() {
18-
TreeNode root(1);
19-
TreeNode t2(2);
20-
TreeNode t3(3);
21-
TreeNode t4(4);
22-
TreeNode t5(5);
23-
TreeNode t6(6);
24-
TreeNode t7(7);
25-
TreeNode t8(8);
26-
TreeNode t9(9);
27-
28-
root.left = &t2;
29-
root.right = &t3;
30-
t2.left = &t4;
31-
t2.right = &t5;
32-
t3.right = &t6;
33-
t4.left = &t7;
34-
t4.right = &t8;
35-
t8.left = &t9;
36-
37-
Solution s;
38-
std::cout << s.maxDepth(&root) << std::endl;
39-
40-
return 0;
41-
}
1+
#include <iostream>
2+
#include "solution.h"
3+
4+
// Test Unit
5+
// Create a tree for test
6+
// 1
7+
// / \
8+
// 2 3
9+
// / \ \
10+
// 4 5 6
11+
// / \
12+
// 7 8
13+
// /
14+
// 9
15+
16+
17+
int main() {
18+
TreeNode root(1);
19+
TreeNode t2(2);
20+
TreeNode t3(3);
21+
TreeNode t4(4);
22+
TreeNode t5(5);
23+
TreeNode t6(6);
24+
TreeNode t7(7);
25+
TreeNode t8(8);
26+
TreeNode t9(9);
27+
28+
root.left = &t2;
29+
root.right = &t3;
30+
t2.left = &t4;
31+
t2.right = &t5;
32+
t3.right = &t6;
33+
t4.left = &t7;
34+
t4.right = &t8;
35+
t8.left = &t9;
36+
37+
Solution s;
38+
std::cout << s.maxDepth(&root) << std::endl;
39+
40+
return 0;
41+
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/**
2-
* Definition for binary tree
3-
* struct TreeNode {
4-
* int val;
5-
* TreeNode *left;
6-
* TreeNode *right;
7-
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8-
* };
9-
*/
10-
struct TreeNode {
11-
int val;
12-
TreeNode *left;
13-
TreeNode *right;
14-
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
15-
};
16-
17-
class Solution {
18-
public:
19-
int maxDepth(TreeNode *root) {
20-
if (root == NULL) return 0;
21-
return std::max(maxDepth(root->left), maxDepth(root->right))+1;
22-
}
23-
};
1+
/**
2+
* Definition for binary tree
3+
* struct TreeNode {
4+
* int val;
5+
* TreeNode *left;
6+
* TreeNode *right;
7+
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8+
* };
9+
*/
10+
struct TreeNode {
11+
int val;
12+
TreeNode *left;
13+
TreeNode *right;
14+
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
15+
};
16+
17+
class Solution {
18+
public:
19+
int maxDepth(TreeNode *root) {
20+
if (root == NULL) return 0;
21+
return std::max(maxDepth(root->left), maxDepth(root->right))+1;
22+
}
23+
};
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
#include <iostream>
2-
#include "solution.h"
3-
4-
// Test Unit
5-
// Create a tree for test
6-
// 1
7-
// / \
8-
// 2 3
9-
// / \ \
10-
// 4 5 6
11-
// / \
12-
// 7 8
13-
// /
14-
// 9
15-
16-
int main() {
17-
TreeNode root1(1);
18-
TreeNode root2(1);
19-
TreeNode t2(2);
20-
TreeNode t3(3);
21-
TreeNode t4(4);
22-
TreeNode t5(5);
23-
TreeNode t6(6);
24-
TreeNode t7(7);
25-
TreeNode t8(8);
26-
TreeNode t9(9);
27-
28-
root1.left = &t2;
29-
root1.right = &t3;
30-
root2.left = &t2;
31-
root2.right = &t3;
32-
t2.left = &t4;
33-
t2.right = &t5;
34-
t3.right = &t6;
35-
t4.left = &t7;
36-
t4.right = &t8;
37-
t8.left = &t9;
38-
39-
Solution s;
40-
std::cout << s.isSameTree(&root1, &root2) << std::endl;
41-
42-
return 0;
43-
}
1+
#include <iostream>
2+
#include "solution.h"
3+
4+
// Test Unit
5+
// Create a tree for test
6+
// 1
7+
// / \
8+
// 2 3
9+
// / \ \
10+
// 4 5 6
11+
// / \
12+
// 7 8
13+
// /
14+
// 9
15+
16+
int main() {
17+
TreeNode root1(1);
18+
TreeNode root2(1);
19+
TreeNode t2(2);
20+
TreeNode t3(3);
21+
TreeNode t4(4);
22+
TreeNode t5(5);
23+
TreeNode t6(6);
24+
TreeNode t7(7);
25+
TreeNode t8(8);
26+
TreeNode t9(9);
27+
28+
root1.left = &t2;
29+
root1.right = &t3;
30+
root2.left = &t2;
31+
root2.right = &t3;
32+
t2.left = &t4;
33+
t2.right = &t5;
34+
t3.right = &t6;
35+
t4.left = &t7;
36+
t4.right = &t8;
37+
t8.left = &t9;
38+
39+
Solution s;
40+
std::cout << s.isSameTree(&root1, &root2) << std::endl;
41+
42+
return 0;
43+
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/**
2-
* Definition for binary tree
3-
* struct TreeNode {
4-
* int val;
5-
* TreeNode *left;
6-
* TreeNode *right;
7-
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8-
* };
9-
*/
10-
11-
struct TreeNode {
12-
int val;
13-
TreeNode *left;
14-
TreeNode *right;
15-
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
16-
};
17-
18-
class Solution {
19-
public:
20-
bool isSameTree(TreeNode *p, TreeNode *q) {
21-
if (p && q) return (p->val == q->val) && isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
22-
else if (!p && !q) return true;
23-
else return false;
24-
}
25-
};
1+
/**
2+
* Definition for binary tree
3+
* struct TreeNode {
4+
* int val;
5+
* TreeNode *left;
6+
* TreeNode *right;
7+
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8+
* };
9+
*/
10+
11+
struct TreeNode {
12+
int val;
13+
TreeNode *left;
14+
TreeNode *right;
15+
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
16+
};
17+
18+
class Solution {
19+
public:
20+
bool isSameTree(TreeNode *p, TreeNode *q) {
21+
if (p && q) return (p->val == q->val) && isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
22+
else if (!p && !q) return true;
23+
else return false;
24+
}
25+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include <iostream>
2-
#include "solution.h"
3-
4-
int main() {
5-
Solution s;
6-
std::cout << s.numTrees(3) << std::endl;
7-
std::cout << s.numTrees(19) << std::endl;
8-
9-
return 0;
10-
}
1+
#include <iostream>
2+
#include "solution.h"
3+
4+
int main() {
5+
Solution s;
6+
std::cout << s.numTrees(3) << std::endl;
7+
std::cout << s.numTrees(19) << std::endl;
8+
9+
return 0;
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include <climits>
2-
3-
class Solution {
4-
public:
5-
int numTrees(int n) {
6-
long long res = 1;
7-
for (int i=1; i<=n; ++i)
8-
res = res*2*(2*i-1)/(i+1);
9-
return res > INT_MAX ? 0 : res;
10-
}
11-
};
1+
#include <climits>
2+
3+
class Solution {
4+
public:
5+
int numTrees(int n) {
6+
long long res = 1;
7+
for (int i=1; i<=n; ++i)
8+
res = res*2*(2*i-1)/(i+1);
9+
return res > INT_MAX ? 0 : res;
10+
}
11+
};
File renamed without changes.

0 commit comments

Comments
 (0)