mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 04:06:51 +08:00
Merge pull request #738 from andywang0607/242_rust
增加0242.有效的字母异位词Rust語言版本
This commit is contained in:
@ -256,6 +256,25 @@ class Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Rust:
|
||||||
|
```rust
|
||||||
|
impl Solution {
|
||||||
|
pub fn is_anagram(s: String, t: String) -> bool {
|
||||||
|
let mut record = vec![0; 26];
|
||||||
|
|
||||||
|
let baseChar = 'a';
|
||||||
|
|
||||||
|
for byte in s.bytes() {
|
||||||
|
record[byte as usize - baseChar as usize] += 1;
|
||||||
|
}
|
||||||
|
for byte in t.bytes() {
|
||||||
|
record[byte as usize - baseChar as usize] -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
record.iter().filter(|x| **x != 0).count() == 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
## 相关题目
|
## 相关题目
|
||||||
|
|
||||||
* 383.赎金信
|
* 383.赎金信
|
||||||
|
Reference in New Issue
Block a user