Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SubString Quest Problem Description Raju and Rani like playing with strings, exploring the interesting patterns of smaller parts within them, called substrings. Presently, they are
SubString Quest Problem Description Raju and Rani like playing with strings, exploring the interesting patterns of smaller parts within them, called substrings. Presently, they are engrossed in a string-centric game and it is Raju's turn. His task involves two strings provided by Rani, namely S1 and S2. Raju is tasked with dividing the first string S1 into the fewest possible substrings, ensuring that all resulting substrings, whether in their original or reversed order, are present in S2 while also aiming for maximizing the length of current substring. For example, if S1 = "vanaja" and S2 = "rvanpnaja", then the output will be van|aja rather than va|naja. Note : The letter in the ith position in S1 can be used in exactly one substring of S1. The letters from S2 can be reused any number of times but the letters from S1 can be used only once. The letters are case sensitive in both the strings. Constraints 1 <= S1, S2 <= 10000 The two strings S1, S2 consist of lower and upper case characters only. Input First line consists of a string S1. Second line consists of string S2. Output Print the string S1 as a concatenation of sub strings
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Lets break it down a For function f mathbbZ ightarrow mathbbR where fn 2n ...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