Astro 自动生成 Open Graph & Twitter card 图片😄 #15
Replies: 5 comments 2 replies
-
测试代码片段 use std::collections::HashMap;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut map = HashMap::new();
for (i, &num) in nums.iter().enumerate() {
match map.get(&(target - num)) {
Some(&index) => return vec![index as i32, i as i32],
None => map.insert(num, i),
};
}
vec![]
}
fn main() {
let nums = vec![2, 7, 11, 15];
let target = 9;
let result = two_sum(nums, target);
println!("{:?}", result); // 输出:[0, 1]
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Astro 自动生成 Open Graph & Twitter card 图片😄
本篇文章教你在 Astro 为你的文章自动生成 Open Graph & Twitter card 图片。
https://liruifengv.com/posts/astro-auto-gen-og-image/
Beta Was this translation helpful? Give feedback.
All reactions