最近在學習馬拉車演算法,簡單記錄一下心得。(如有疏漏,請指出 先看 模板題 ,要求最長迴文串的長度。 首先思考樸素演算法,顯然是 $O(n^3)$ ,無法透過。而馬拉車演算法能將時間複雜度最佳化到 $O(n)$。 性質 對於一個迴文字串,必然有一個對稱中心,在對稱中心兩側的部分均全等。 一個迴文字串對稱之後得到的一定也是迴文字串 即 aba x aba 但是對於奇數、偶數長度的迴文字串,這個對稱中…
Louis Aeilot's Blog 的其他文章
- How Close Is FlashAttention to the Limit? Understanding Attention Through Data Movement
- Beyond FLOPs: How COSMA Builds Parallel Matrix Multiplication from Communication Bounds
- The Red-Blue Pebble Game: Why Faster Processors Still Have to Move Data
- Git Needs a Trash Can
- RoPE: Properties, Patterns, and Long-Context Behavior
讨论
登录后参与讨论
还没有评论,来说第一句吧。