[理工] 106 台聯大電機 資料結構 第五題 字串週

看板Grad-ProbAsk作者 (x3767x)時間5年前 (2020/12/26 22:15), 5年前編輯推噓2(202)
留言4則, 1人參與, 5年前最新討論串1/1
https://i.imgur.com/mUHXvFo.jpg
想請問這題要怎麼樣time complexity才能在O(n)之內完成 我怎麼想都會變成O(n^2) 原本也試過KMP但寫起來怪怪好像不一樣 ----- Sent from JPTT on my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.139.152.136 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1608992135.A.33E.html

12/26 22:29, 5年前 , 1F
請參考prefix function
12/26 22:29, 1F

12/26 22:36, 5年前 , 2F
講清楚一點好了
12/26 22:36, 2F

12/26 22:36, 5年前 , 3F
pi為prefix function
12/26 22:36, 3F

12/26 22:36, 5年前 , 4F
k會是n-pi[n]
12/26 22:36, 4F
了解了!感謝a大 ※ 編輯: x3767x (218.173.80.43 臺灣), 12/26/2020 22:50:24
文章代碼(AID): #1VvqM7C- (Grad-ProbAsk)