Skip to content

Commit

Permalink
add solusion
Browse files Browse the repository at this point in the history
  • Loading branch information
caixiangyue committed Sep 4, 2023
1 parent 17ccfaf commit fdb841a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
20 changes: 20 additions & 0 deletions 0142.h
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) {


}
};
}
24 changes: 24 additions & 0 deletions 0242.h
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;
}
};
}
3 changes: 2 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include <vector>
#include <unordered_map>
#include <unordered_map>
#include <string>

0 comments on commit fdb841a

Please sign in to comment.