Skip to content

Commit

Permalink
Sync LeetCode submission - Valid Anagram (rust)
Browse files Browse the repository at this point in the history
  • Loading branch information
hucancode committed Dec 16, 2023
1 parent 833e2e1 commit 9213137
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions leetcode/problems/valid_anagram/solution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
impl Solution {
pub fn is_anagram(s: String, t: String) -> bool {
let mut a = vec![0; 1+'z' as usize];
let mut b = vec![0; 1+'z' as usize];
for c in s.chars() {
a[c as usize] += 1;
}
for c in t.chars() {
b[c as usize] += 1;
}
a.iter().zip(b.iter()).all(|(a,b)| a == b)
}
}

0 comments on commit 9213137

Please sign in to comment.