Блог пользователя KarimElSheikh

Автор KarimElSheikh, история, 6 лет назад, По-английски

Is it possible to extend Manacher's algorithm to include information about the longest palindromic substring that starts at every position and still keep the O(N) time complexity?

For example the string cbcbaaabc should give the array [3, 3, 7, 5, 3, 2, 1, 1, 1] which corresponds to the strings cbc, bcb, cbaaabc, baaab, aaa, aa, a, b, c respectively

What about an O(NlogN) solution?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор KarimElSheikh, история, 9 лет назад, По-английски
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор KarimElSheikh, история, 9 лет назад, По-английски

There are some few problems I came across like Fish and Virus synthesis which seem to have solutions with BFS traversal and typical DP minimization/maximization function. I want to practice this technique because normally when I think of coding a DP solution I only think of DFS traversal, any ideas of problems which are best solved using this technique?

EDIT: Just a clarification this DP style is usually a "Reverse" BFS Traversal of the states where we travel from the leaf nodes upwards level by level and converge to the final state

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится