Question: In same Manachers algorithm O(N) can we find all distinct palindromic substring/subarray ? for example if we have [1, 3, 4, 3, 1, 1, 2
In same Manachers algorithm O(N) can we find all distinct palindromic substring/subarray ? for example if we have [1, 3, 4, 3, 1, 1, 2 , 2, 1 5] So here, we have 3 distinct [1, 3, 4, 3, 1] [3, 4, 3], [1, 2, 2, 1]. With O(N) we can get 2 distinct substring but if we go expanding each substring/subarray which is greater than 3 then we will need N2 computation which increases complexity. Is there way to to in efficient manner? Take example of [1]*1000 or [2]*1000 so we can do in some seconds.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
