def FindKthToTail(head, k):
if head == None: return None
front = head; back = head
steps = 0
# get | front - head | = k
while front and steps < k:
front = front.next
steps += 1
# less than k nodes
if front == None: return None
while front:
front = front.next
back = back.next
return back
與面試題37:兩個鏈表的第一個公共結點使用的是同樣的策略。
【劍指offer】Q15:鏈表中的倒數第K個結點
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
一文搞懂DevOps、DataOps、MLOps、AIOps:所有“Ops”的比較
原創
2024-06-07 14:08:38
盤點一個Pandas數據分組的問題
原創
2024-06-07 10:02:02
sublime text4 定製記錄
原創
2024-06-07 01:14:07
sublime text定製
原創
2024-06-07 01:14:04
無需搭建環境,零門檻帶你體驗Open-Sora文生視頻應用
原創
2024-06-06 10:56:52
有沒有python在flask框架下開發的實際案例?
原創
2024-06-06 10:01:59
[oeasy]python020在遊戲中體驗數值自由_勇闖地下城_終端文字遊戲
繼續運行 ?* 回憶上次內容 上次使用shell環境中的命令 命令 作用 c
原創
2024-06-05 12:31:14
Python網絡爬蟲要清理cookies 才能再爬,有啥解決方法嘛?
原創
2024-06-05 10:02:06
自動化Reddit圖片收集:Python爬蟲技巧
原創
2024-06-05 00:06:19
什麼是LLM大模型訓練,詳解Transformer結構模型
原創
2024-06-04 11:09:34
直播預告|手把手教你玩轉 Milvus Lite !
原創
2024-06-03 21:25:13
重磅推出:Milvus Lite 正式上線,幾秒內即可輕鬆搭建 GenAI 應用
原創
2024-06-02 02:22:45
peewee的動態Model
原創
2024-05-31 21:48:26
一站式鏈路追蹤:阿里雲的端到端解決方案
原創
2024-05-31 21:13:44