You are given two strings S1 and S2. Let us define X as a sub-string (which can also be…
- User
You are given two strings S1 and S2. Let us define X as a sub-string (which can also be a circular substring) of S2 such that none of the characters of S1 are present in X.
Note: Circular substring of a string refers to a substring that consists of some suffix of the string followed by some prefix of the string.
Task
Determine the largest possible string S that can be formed by using all the characters of S1 and X. You can arrange the characters in any order. If there are multiple answers, print the lexicographically largest string among them.
Note: Strings S1 and S2 consist of only lowercase alphabets. Also, it is guaranteed that you will be able to select a non-empty substring.
Example
If ="abc" and ="deabcfg". In this case, can be "fgde" (as X can be circular). Largest possible string S is therefore, "gfedcba". If ="abc" and ="aadecc". In this case, can be "de". Largest possible string S is therefore, "edcba". Function description
Complete the Circular_str function provided in the editor. The function takes the following 4 parameters and returns the string S as described in the problem:
N: Represents the length of string S1 S1: Represents the string S1 M: Represents the length of string S2 S2: Represents the string S2 Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
The first line contains a single integer N denoting the length of S1. The second line contains a string S1. The third line contains a single integer M denoting the length of S2. The fourth line contains a string S2. Output format
Print the string S.
Constraints
SAMPLE INPUT 3 abc 5 acdef SAMPLE OUTPUT fedcba Explanation You can select sub-string = "def".
The lexicographically maximum possible string that can be formed = "fedcba". In python
- Assistant