Question
You are given a string S of length N and a string array Arr of tength M. Find the longest subsequence of S in which
You are given a string S of length N and a string array Arr of tength M.
Find the longest subsequence of S in which each substring of length 2 is
present in the string array Arr.
Notes:
A substring of a string is a contiguous subsequence of that string.
Make a function with parameters (String S, ListArr) and return an INTEGER denoting the longest subsequence of S in which each substring of length 2 is present in the string array Arr.
Sample Test cases:
Case 16abcdef1ab
OUTPUT2
Case 26abacaf2aaad
OUTPUT4
Case 36asgfsd4asagaffs
MAKE SURE ALL TEST CASES PROVIDED RUNS SUCCESSFULLY. THEN SURELY I WILL LIKE THE SOLUTION.
P.S: CODE IN ANY LANGUAGE, CAN TRY IN JAVA.
The first line contains an integer, N, denoting the length of the string. The next line contains a string, S, denoting the given string. The next line contains an integer, M, denoting the number of elements in Arr. Each line i of the M subsequent lines (where 0
Step by Step Solution
3.43 Rating (143 Votes )
There are 3 Steps involved in it
Step: 1
Public class LongestSubSequence public static void Mainstrin...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