mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
新增 哈希表部分的 C#版
This commit is contained in:
@@ -307,6 +307,25 @@ impl Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
C#:
|
||||
```csharp
|
||||
public bool IsAnagram(string s, string t) {
|
||||
int sl=s.Length,tl=t.Length;
|
||||
if(sl!=tl) return false;
|
||||
int[] a = new int[26];
|
||||
for(int i = 0; i < sl; i++){
|
||||
a[s[i] - 'a']++;
|
||||
a[t[i] - 'a']--;
|
||||
}
|
||||
foreach (int i in a)
|
||||
{
|
||||
if (i != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
## 相关题目
|
||||
|
||||
* 383.赎金信
|
||||
|
||||
Reference in New Issue
Block a user