Rust Leetcode链表实现

Rust LinkedList 定义 Leetcode: rust 如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } /// 单链表 #[derive(Debug)] struct LinkedList<T> { head: Option<Box<Node<T>>>, } Go 如下: ...

2024-02-01 14:00 · 7 min · 3111 words · Reid