nth letter of lexicographically ordered substrings

91 Views Asked by At

Given a string of letters, how do we efficiently find the nth letter among the lexicographically ordered substrings of the string? For example, if the string is 'aab', the lexicographically ordered substrings form the larger string 'aaaaaababb' (the substrings are a, a, aa, aab, ab, b) and the 7th letter is 'b