LCParray
LCParray, or the LCP array, is a data structure used in string processing. It records, for each adjacent pair of suffixes in the suffix array of a string S, the length of the longest common prefix between those two suffixes. Formally, for a string S of length n and SA[0..n-1] as the suffix array, the LCP array LCP[0..n-1] is defined by LCP[i] = LCP(S[SA[i]..], S[SA[i-1]..]) for i > 0, and LCP[0] = 0.
Construction and properties: Given S and its SA, the LCP array can be computed in O(n) time
Queries and RMQ: The LCP array enables rapid LCP queries between arbitrary suffixes via a range minimum
Applications: LCP arrays underpin efficient pattern matching, substring search, counting distinct substrings, data compression schemes, and
Example: For the string "banana", the suffix array is SA = [5, 3, 1, 0, 4, 2], and