Posts

Showing posts from March 13, 2021

Find Case Sensitive Pattern

 Find Case Sensitive Pattern  PROBLEM STATEMENT : The program must accept two string values S and P containing only alphabets as the input. The program must print all possible substrings of S that match the pattern P. If a substring matches the pattern P, then the case of each alphabet in the pattern P matches with the corresponding alphabet in the substring. The substrings must be printed in the order of their occurrence. If there is no such substring in S, then the program must print -1 as the output.  Boundary Condition(s):   1 <= Length of P <= Length of S <= 1000  Input Format:   The first line contains S.  The second line contains P.  Output Format:  The lines, each contains a substring matches the pattern P or the first line contains -1.  Example Input/Output 1: Input: ( ) SkillRack Do Output: Sk Ra Explanation:  Here the given pattern is Do.  The case of each alphabet in the pattern Do matches the subs...

Longest Substring Reverse Search

Longest Substring Reverse Search   PROBLEM STATEMENT : The program must accept two string values S1 and S2 as the input. The program must print the longest substring of S1 which occurs in S2 in reverse order as the output. If two or more such longest substrings occur in S1, then the program must print the first occurring substring as the output. If there is no such substring, then the program must print -1 as the output. Boundary Condition(s):    1 <= Length of S1, S2 <= 1000 Input Format:   The first line contains S1.  The second line contains S2. Output Format:   The first line contains the longest substring of S1 which occurs in S2 in reverse order.  Example Input/Output 1:   Input:   monkey  nomad  Output:  mon Explanation:   Here S1 = monkey and S2 = nomad.  The longest substring mon occurs in the string nomad in reverse order.  So mon is printed as the output.  Example Input/Output 2: Input: sk...