Lexicographically Bigger String
Given lowercase alphabet strings s
and t
of the same length, return whether there’s some anagram of s
, say a
, and some anagram of t
, say b
, such that:
a[i] ≤ b[i]
for all0 ≤ i < n
orb[i] ≤ a[i]
for all0 ≤ i < n
.
Constraints
1 ≤ n = m ≤ 100,000
wheren
andm
are the lengths ofs
andt
.
https://binarysearch.com/problems/Lexicographically-Bigger-String
Examples
Example 1
Input
- s =
adc
- t =
bec
Output
- answer =
True
Explanation
We can have a = "acd"
and b = "bce"
and we have:
"a" ≤ "b"
"c" ≤ "c"
"d" ≤ "e"
Leave a comment