2. Palindrome Subsequences For a string s which consists only of characters ' 0 ' and ' 1 ', find the number of subseque
Posted: Thu Jul 14, 2022 2:10 pm
2. Palindrome Subsequences For a string s which consists only of characters ' 0 ' and ' 1 ', find the number of subsequences of length 5 which are palindromes. As the answer can be really big, return the answer mod (109+7) Note - A palindrome is a string that reads the same backward as forward. - A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements. - Two subsequences are considered different if the indices of the string that forms the subsequences are different. Example s=−0100110n Using 1-based indexing, the 5 subsequences are - indices (1,2,3,6,7)→01010 - indices (1,2,3,5,7)→01010 - indices (1,2,4,6,7)→01010 - indices (1,2,4,5,7)→01010 - indices (1,2,5,6,7)→01110 5 modulo (109+7)=5 10 Function Description Complete the function