MCPcopy Create free account
hub / github.com/douchuan/algorithm / find

Function find

src/ll/kth2tail.rs:9–11  ·  view source on GitHub ↗
(l: &LinkedList<T>, k: usize)

Source from the content-addressed store, hash-verified

7use std::ptr::NonNull;
8
9pub fn find<T>(l: &LinkedList<T>, k: usize) -> Option<NonNull<Node<T>>> {
10 unsafe { do_find(l.head, k) }
11}
12
13/// 设链表的长度为 N。设置两个指针 P1 和 P2,先让 P1 移动 K 个节点,
14/// 则还有 N - K 个节点可以移动。此时让 P1 和 P2 同时移动,可以知道

Callers 1

find_kth2tailFunction · 0.50

Calls 1

do_findFunction · 0.85

Tested by 1

find_kth2tailFunction · 0.40