Palindromic subseqence: implementation