20241024 finished.

This commit is contained in:
2024-10-24 09:08:13 +08:00
parent 3102da99a8
commit bce8de1c85
266 changed files with 2321 additions and 2014 deletions

View File

@@ -3,7 +3,6 @@
*/
pub struct Solution {}
// submission codes start here
use std::collections::HashMap;
@@ -16,10 +15,10 @@ impl Solution {
*entry += 1;
}
let s : Vec<char> = s.chars().collect();
let s: Vec<char> = s.chars().collect();
let mut s_map = HashMap::new();
let (mut i , mut j) = (0, 0);
let (mut i, mut j) = (0, 0);
let mut result_left = 0;
let mut result_length = usize::MAX;
@@ -51,7 +50,7 @@ impl Solution {
}
}
fn check_map(s : &HashMap<char, i32>, t : &HashMap<char, i32>) -> bool {
fn check_map(s: &HashMap<char, i32>, t: &HashMap<char, i32>) -> bool {
for (key, value) in t {
match s.get(key) {
Some(real_value) => {
@@ -77,6 +76,9 @@ mod tests {
#[test]
fn test_76() {
assert_eq!("BANC".to_owned(), Solution::min_window("ADOBECODEBANC".to_owned(), "ABC".to_owned()));
assert_eq!(
"BANC".to_owned(),
Solution::min_window("ADOBECODEBANC".to_owned(), "ABC".to_owned())
);
}
}