FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #423 from wangfanstar/057-wangfan · algorithm001/algorithm@f9f23d9 · GitHub

Commit f9f23d9

Browse files
Merge pull request #423 from wangfanstar/057-wangfan
057 wangfan week2
2 parents 3244457 + 19994c0 commit f9f23d9

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎Week_02/id_57/leetcode_242_057.cpp‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class Solution {
2+
public:
3+
bool isAnagram(string s, string t) {
4+
int A[26] = {0};
5+
int B[26] = {0};
6+
int i = 0;
7+
int j = 0;
8+
9+
while(s[i] != '\0')
10+
{
11+
j = s[i] - 'a';
12+
A[j]++;
13+
i++;
14+
}
15+
16+
i = 0;
17+
while(t[i] != '\0')
18+
{
19+
j = t[i] - 'a';
20+
B[j]++;
21+
i++;
22+
}
23+
24+
for(i = 0; i < 26; i++)
25+
{
26+
if(A[i]!=B[i])
27+
return false;
28+
}
29+
return true;
30+
31+
}
32+
};

‎Week_02/id_57/leetcode_671_057.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
4+
int findSecondMinimumValue(TreeNode* root) {
5+
if(!root->left) return -1;
6+
int left = (root->left->val == root->val) ? findSecondMinimumValue(root->left) : root->left->val;
7+
int right = (root->right->val == root->val) ? findSecondMinimumValue(root->right) : root->right->val;
8+
return ((left == -1 ) || (right == -1)) ? max(left,right) : min(left,right);
9+
10+
}
11+
};

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL