Description
Solutions
Largest Lexicographical Substring ๐ฟ
๐RELATED PROBLEMS
Given two strings A
and B
, your task is to output the largest
lexicographically ordered substring of string B
that makes string B
a superstring of string A
. If no such substring exists, output -1
.
A superstring is a string that contains all the characters present in another string, irrespective of their order.
Example 1:
Input: A = "abc", B = "abcab"
Output: "cab"
Explanation:StringB
is a superstring of stringA
because it contains all the characters ofA
in various sequences. Among these sequences, ("cab", "abc", "bca") meet the conditions, and the largest lexicographically ordered substring among them is "cab".
Constraints:
Unknwon for now ๐

Related Problems
Testcase
Result
Case 1
input:
output: