Cached the suffix and LCP arrays to prevent unnecessary recalculation.