- leetcode字符串入参用into_bytes()处理后可以使用下标访问
- 注意整数溢出,leetcode运行Rust代码溢出时不会panic
- 尽量用into_iter()代替iter()
- 排序用sort_unstable(快速排序)比sort(归并排序)快
- 了解一些In-Place操作API(例如 swap,replace, take)
utils和题解:https://github.com/aylei/leetcode-rust 他的utils可以重点学习一下
刷题口诀:https://leetcode.cn/circle/discuss/Qy2X5E/view/EBNB5R/
let x: u32 = 10;let s: String = x.to_string();println!("{:?}", s.as_bytes()[0]-b'0');let s: String = String::from("abc");//If you are sureprintln!("{}", s.chars().nth(1).unwrap());//or if notprintln!("{}", s.chars().nth(2).expect("message"));
fn main() {let str = String::from("abcdefgh");str.chars().collect::<Vec<char>>()}
