/returns the lcp for any two strings *int computelcpconst string const string int whilei length& length& = ++ireturn /fill in the suffix array and lcp information for string str str is the input string sa is an existing array to place the suffix array lcp is an existing array to place the lcp information *void createsuffixarrayslowconst string strvector savector lcp ifsa size!str length|lcp size!str lengththrow invalid_argument"mismatched vector sizes}size_t str length)const char *cstr str c_str)vector suffixesn )forint ++ suffixesi cstr istd::sortbeginsuffixes )endsuffixes )[const char * const char * return strcmps )forint ++ sai suffixesi cstrlcp forint ++ lcpi computelcpsuffixesi ]suffixesi )figure simple algorithm to create suffix array and lcp array