mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
14 lines
457 B
HTML
14 lines
457 B
HTML
<p>Implement an algorithm to find the kth to last element of a singly linked list. Return the value of the element.</p>
|
|
|
|
|
|
|
|
<p><strong>Note: </strong>This problem is slightly different from the original one in the book.</p>
|
|
|
|
|
|
|
|
<p><strong>Example: </strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input: </strong> 1->2->3->4->5 和 <em>k</em> = 2
|
|
|
|
<strong>Output: </strong>4</pre>
|
|
|
|
|
|
|
|
<p><strong>Note: </strong></p>
|
|
|
|
|
|
|
|
<p>k is always valid.</p>
|
|
|