Problem ยท String
Largest Lexicographical Substring ๐ฟ
Learn this problemProblem statement
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.
Function
getLargestLexicographicalSubstring(A: String, B: String) โ StringExamples
Example 1
A = "abc"B = "abcab"return = "cab"String
B is a superstring of string A because it contains all the
characters of A 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 ๐More Google problems
- Maximum Coins With Moving TokensOA ยท Seen Aug 2026
- Maximum Elements With a Common DigitOA ยท Seen Aug 2026
- Decode StringPHONE SCREEN ยท ONSITE INTERVIEW ยท Seen Jul 2026
- Longest Subarray with Sum at Most KOA ยท Seen Jul 2026
- Maximum Sum Path Between Two Leaf NodesOA ยท Seen Jul 2026
- Count Prefix Matches in a Sorted ArrayONSITE INTERVIEW ยท Seen Jul 2026
- Phone Keypad Letter CombinationsONSITE INTERVIEW ยท Seen Jul 2026
- Split a Log Outside QuotesONSITE INTERVIEW ยท Seen Jul 2026