I want to write a function that outputs a suffix array. This is what I have so far:
def suffixArray(s):
sa = []
for i in range(len(s)):
suffix= sorted([s[i:]])
sa = [len(s)-len(suffix[i:])
return list(sa)
This outputs an error because I think I'm missing an additional if statement but I'm not really sure how to go about it. And yes, I know that there are probably easier ways to obtain a suffix array but I'm a beginner in python and there are few functions that I can use. Any help is appreciated. Thanks
Also here's an example of what I want my input and output to be: input --> suffixArray('banana') output--> [5, 3, 1, 0, 4, 2]