Judge Solution Idea:

Find the ending/starting positions of all distinct palindromic substrings using Palindromic Tree (Err Tree). Sort all of them. To design the comparator function of sorting, consider two distinct substrings. You know only their starting and ending positions (and length), now you need to check which of them is lexicogrpahically smaller. To do so, you can find the last position of the substrings upto which they match in log2(length) using hashing and binary search. Which one is lexicographically smaller will depend on the next position.

Alternate Solution: Manacher + Hashing

Statistics

71% Solution Ratio
SMAN2901Earliest, Oct '19
samiulsamiFastest, 0.0s
Shuvo_MalakarLightest, 5.5 kB
steinumShortest, 1841B
Toph uses cookies. By continuing you agree to our Cookie Policy.