I found an implementation of suffix arrays here (not sure if it's the most efficient so if there's any better I'd be glad to know).
For a given string:
data = '1034408'*10
It generates the following suffix array:
suffix_array = [64, 57, 50, 43, 36, 29, 22, 15, 8, 1, 68, 61, 54, 47, 40, 33, 26, 19, 12, 5, 63, 56, 49, 42, 35, 28, 21, 14, 7, 0, 65, 58, 51, 44, 37, 30, 23, 16, 9, 2, 67, 60, 53, 46, 39, 32, 25, 18, 11, 4, 66, 59, 52, 45, 38, 31, 24, 17, 10, 3, 69, 62, 55, 48, 41, 34, 27, 20, 13, 6]
Having:
len(suffix_array) = 70
max(suffix_array) = 69
suffix_array.index(max(suffix_array)) = 60
Is a suffix tree better suited for this task?