Actually 0ms
IntuitionWell, my first instinct was right, to proceed with VecDeque, but to my dismay it took 10ms execution time, I also struggled to recognize that I needed
# Intuition
Well, my first instinct was right, to proceed with `VecDeque`, but to my dismay it took $\text{10ms}$ execution time, I also struggled to recognize that I needed to accumulate the solution key in the histograms and the final sum, but figured it out.

Then I went off the rails with optimizing to get the runtime down to $\text{0ms}$.

First order was to get rid of `VecDeque::rotate_right` and try using indexing, I struggled to match the behavior but picked something that seems OK within bounds. It was still around $\text{10ms}$.

I unrolled the transformation loop over `t` as shown below which seemed to contribute some, and then additionally using `into_iter` where possible (before summing the histogram, and when initializing it from `s`) substantially improved performance, and the test bench reported $\text{0ms}$.

Check it out https://leetcode.com/submissions/detail/1597056933/

# Code
```rust []
impl Solution {
    pub fn length_after_transformations(s: String, t: i32) -> i32 {
        let t = t as usize;
        let st = 26*t;
        let mut h = s.as_bytes().into_iter().fold(
            vec![0u64; 26],
            |mut vd, c| {
                match vd.get_mut(((c - b'a') as usize)) {
                    Some(entry) => {
                        *entry += 1;
                    }, 
                    _ => panic!("wat")
                } vd
            }
        );

        (0..t).step_by(8).for_each(
            #[inline(always)]
            |i| { 
            let left_idx = (st - i).rem_euclid(26);
            let right_idx = (st - i - 1).rem_euclid(26);
            h[left_idx] += h[right_idx] % (1_000_000_007);
            if i+1 < t {
                let left_idx = (st - i - 1).rem_euclid(26);
                let right_idx = (st - i - 2).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+2 < t {
                let left_idx = (st - i - 2).rem_euclid(26);
                let right_idx = (st - i - 3).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+3 < t {
                let left_idx = (st - i - 3).rem_euclid(26);
                let right_idx = (st - i - 4).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+4 < t {
                let left_idx = (st - i - 4).rem_euclid(26);
                let right_idx = (st - i - 5).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+5 < t {
                let left_idx = (st - i - 5).rem_euclid(26);
                let right_idx = (st - i - 6).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+6 < t {
                let left_idx = (st - i - 6).rem_euclid(26);
                let right_idx = (st - i - 7).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
            if i+7 < t {
                let left_idx = (st - i - 7).rem_euclid(26);
                let right_idx = (st - i - 8).rem_euclid(26);
                h[left_idx] += h[right_idx] % (1_000_000_007);
            }
        });

        (h.into_iter().fold(0, |sum, next| (sum + next) % (1_000_000_007)) ) as i32
    }
}
```
['Rust']