From 07f347c337b1407f8618ba9c3cedebe76c6d3eb2 Mon Sep 17 00:00:00 2001 From: Jiacheng Dong <2334173653@qq.com> Date: Sun, 24 Dec 2023 14:49:35 +0800 Subject: [PATCH] :sparkles: feat: update 2023-12-24 section --- blogs/2023/2023-12-24/index.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/blogs/2023/2023-12-24/index.md b/blogs/2023/2023-12-24/index.md index 8799efcc9d..8539b40f0e 100644 --- a/blogs/2023/2023-12-24/index.md +++ b/blogs/2023/2023-12-24/index.md @@ -13,6 +13,23 @@ tags: [] [用Rust刷LeetCode之58 最后一个单词的长度](https://mp.weixin.qq.com/s/e4PRZkKojI7VTHPSxoy8VA) +```rs +fn main() { + let len = length_of_last_word(" hello world ".to_owned()); + println!("最后一个单词的长度为:{:?}", len); +} + +pub fn length_of_last_word(s: String) -> usize { + let s = s.trim(); + + let v: Vec<&str> = s.split(' ').collect(); + + v.iter().for_each(|x| println!("{}", x)); + + v.last().unwrap().len() +} +``` + [Golang优雅实现按比例切分流量](https://juejin.cn/post/7274046488752750651) [AIOps在美团的探索与实践——事件管理篇](https://juejin.cn/post/7314975854171291683)