質問 1
Find the kth to last element of a singly linked list.
Use two pointers; one moves k nodes into the list, and then both iterate until the second one reaches the end.
Example:
Input: 1 -> 2 -> 3 -> 4 -> 5, k = 2
Output: 4
復習用に保存
復習用に保存
この項目をブックマークに追加したり、難しい内容としてマークしたり、復習セットに入れたりできます。
役に立ちましたか?
コメントを追加
コメントを見る