pub fn is_permutation_of_palindrome_optimized(phrase: &str) -> bool {
    let mut count_odd = 0;

    const Z: i32 = 'z' as i32;
    const A: i32 = 'a' as i32;
    let mut table: Vec<i32> = vec![-1; (Z - A + 1) as usize];

    phrase.chars().for_each(|c| {
        let x = get_char_number(c);
        if x != -1 {
            table[x as usize] += 1;
            if table[x as usize] % 2 == 1 {
                count_odd += 1;
            } else {
                count_odd -= 1;
            }
        }
    });
    count_odd <= 1
}
/// This function may no necessarily be more optimal than the first one.
/// It has the same big O time and might even be slightly slower.
/// We have eliminated a final iteration through the hash table,
/// but now we have to run a few extra lines of code for each character in the sting.
This function may no necessarily be more optimal than the first one.
It has the same big O time and might even be slightly slower.
We have eliminated a final iteration through the hash table,
but now we have to run a few extra lines of code for each character in the sting.
This function may no necessarily be more optimal than the first one . It has the same big O time and might even be slightly slower . We have eliminated a final iteration through the hash table but now we have to run a few extra lines of code for each character in the sting .
pub fn is_permutation_of_palindrome_optimized(phrase: &str) -> bool {
    let mut count_odd = 0;
    const Z: i32 = 'z' as i32;
    const A: i32 = 'a' as i32;
    let mut table: Vec<i32> = vec![-1; (Z - A + 1) as usize];
    phrase.chars().for_each(|c| {
        let x = get_char_number(c);
        if x != -1 {
            table[x as usize] += 1;
            if table[x as usize] % 2 == 1 {
                count_odd += 1;
            } else {
                count_odd -= 1;
            }
        }
    });
    count_odd <= 1
}
pub fn is_permutation_of_palindrome_optimized ( phrase : & str ) -> bool { let mut count_odd = 0 ; const Z : i32 = 'z' as i32 ; const A : i32 = 'a' as i32 ; let mut table : Vec < i32 > = vec ! [ 1 ( Z A 1 ) as usize ] ; phrase . chars ( ) . for_each ( | c | { let x = get_char_number ( c ) ; if x != - 1 { table [ x as usize ] += 1 ; if table [ x as usize ] % 2 == 1 { count_odd += 1 ; } else { count_odd -= 1 ; } } } ) ; count_odd <= 1 }
This function may no necessarily be more optimal than the first one.
This function may no necessarily be more optimal than the first one .
phrase
&str
phrase
&str