I am coding Skew Algorithm to construct the Suffix Array and I have a long string (length >= 4000). In Skew Algorithm, I have to construct the Triples Array and Sub-strings Array.
For example : I have a string s = 'abcddd'.
- Triples Array is :
'abc', 'bcd', 'cdd', 'ddd' - Sub-strings Array is :
'abcddd', 'bcddd', 'cddd', 'ddd', 'dd', 'd'
This is my solution :
import numpy as np
# example
string = 'abdcb.....' (length >= 4000)
temp = 'abdcb......###' (length >= 4000)
triples_arr = np.array([])
sub_strings = np.array([])
for i in range (0, len(temp) - 3):
triples_arr = np.append(triples_arr, temp[i:i + 3])
sub_strings = np.append(sub_strings, string[i:string_len])
With a long string (length >= 4000), it take a minute to complete.
Is there any solution that I can decrease the processing time of that task?