ShannonHung / ShannonHung.github.io

2 stars 0 forks source link

LeetCode #138 Copy List with Random Pointer - 刷題之旅 | Shannon's Blog 🐟 技術 | 生活 | 旅行 #117

Open ShannonHung opened 2 months ago

ShannonHung commented 2 months ago

https://shannonhung.github.io/posts/leetcode-138-copy-list-with-random-pointer/

1 題目描述 簡單來說,就是要你複製出一個一樣的ListNode結構,而這個ListNode有一個random的參數,這個random參數是指向ListNode中的任意一個節點,這個節點可以是自己,也可以是其他節點。 2 解法 2.0 創建鍊錶 在開始前,我們總是得想辦法先做個測試資料吧…輸入是一個二維陣列,每個元素是一個list,第一個元素是值,第二個元素是random的index,如果是