2. Palindrome Subsequences For a string s which consists only of characters ' 0 ' and ' 1 ', find the number of subseque
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
2. Palindrome Subsequences For a string s which consists only of characters ' 0 ' and ' 1 ', find the number of subseque
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!