3 ms·
I asked ChatGPT for a Rust port, https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fdb045f4c83dda36a540da615393ece0 https://play.rust-lang
by nerpderp82 4y ago
I asked ChatGPT for a Rust port, https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fdb045f4c83dda36a540da615393ece0 https://play.rust-lang.org/?version=stable&mode=debug&editio...
I had to make zero changes, it appears to work.
- twic 4y agoAlthough input.chars().nth() is not good - because of how strings work in Rust, that has to iterate over the string, rather than indexing directly, so O(n) rather than O(1). I think the idiomatic efficient translation would be to use a CharIndices iterator to track each end of the window.