-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17ccfaf
commit fdb841a
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "common.h" | ||
|
||
using namespace std; | ||
|
||
namespace s0142 { | ||
// Definition for singly-linked list. | ||
struct ListNode { | ||
int val; | ||
ListNode *next; | ||
ListNode() : val(0), next(nullptr) {} | ||
ListNode(int x) : val(x), next(nullptr) {} | ||
}; | ||
class Solution { | ||
public: | ||
ListNode *detectCycle(ListNode *head) { | ||
|
||
|
||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "common.h" | ||
|
||
using namespace std; | ||
|
||
namespace s0242 { | ||
|
||
class Solution { | ||
public: | ||
bool isAnagram(string s, string t) { | ||
int a[26]; | ||
if (s.size() != t.size()) return false; | ||
for (int i=0; i<26; i++) | ||
a[i] = 0; | ||
for (int i=0; i<s.size(); i++){ | ||
a[s[i]-'a']++; | ||
a[t[i]-'a']--; | ||
} | ||
for (int i=0; i<26; i++) { | ||
if (a[i] != 0) return false; | ||
} | ||
return true; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#include <vector> | ||
#include <unordered_map> | ||
#include <unordered_map> | ||
#include <string> |