Expand description
§Supply Stacks
There are 2 main challenges to this problem:
- Parsing the input!
- (Rust Specific): The borrow checker prevents mutating a nested
vec
at 2 indices at once.
Functions§
- Parses the input in 2 stages.
- Move elements from stack to stack, reversing each time.
- Move elements from stack to stack without reversing.
- play 🔒Rust’s borrow checker won’t allow us to mutate 2 nested
vec
s simulataneously, so we need to use an temporary intermediatevec
to store the moving crates. For efficiency we can re-use the same vec to prevent unnecessary memory allocations.