Answered step by step
Verified Expert Solution
Question
1 Approved Answer
has to be coded in java thanks ! Counting Subsequences Filename: countseq java Standard Input, Standard Output The Problem Given a sequence of letters as
has to be coded in java thanks !
Counting Subsequences Filename: countseq java Standard Input, Standard Output The Problem Given a sequence of letters as well as subsequence from the original list, you are to count how many times the particular subsequence occurs. Given a sequence co, c, Cn- of letters, we define a subsequence index list to be some ordered list of integers ao, al, an-l. The corresponding subsequence is the string c[ao]c[a].. c[am] For example, given the string, s "engineering", the subsequence defined by the index list 1, 3.4 and 6 is "nine", since s1]n', s[3]- i', s[4]-'n', and s6. The number of times a subsequence occurs in a given sequence is simply the number of unique index lists that generate the given subsequence. For the problem at hand, there are two occurrences of the subsequence "nine". One is the given one and the other is generated by the index list 1, 3, 4 and 5 The Input The first line of the input will contain a single positive integer, n, representing the number of test cases in the file. The following n lines will contain 1 test case each. Each of these lines will have two non-empty strings of lowercase letters separated by a space. The first of these strings is the given input sequence while the second string will be the subsequence for which to search. It is guaranteed that the length of the first string is 1000 or less and that the length of the subsequence is less than or equal to the length of the given sequence. Furthermore, it's guaranteed that the subsequence appears at least once in the sequence For each test case, output a single line with the number of occurrences of the given subsequence The cases will be such that this value is less than 108 Sample Input 2 engineering nine sallysellsseashells sell Sample Output 21Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started