From d03878f010b1c1654b5d76419d8f3cbd324f09f1 Mon Sep 17 00:00:00 2001 From: NotLeonian <75620009+NotLeonian@users.noreply.github.com> Date: Sat, 3 May 2025 16:55:50 +0900 Subject: [PATCH] Add assertation in `lcp_array_arbitrary` --- src/string.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/string.rs b/src/string.rs index 6f03e67..f19e2ed 100644 --- a/src/string.rs +++ b/src/string.rs @@ -242,10 +242,12 @@ pub fn suffix_array(s: &str) -> Vec { // Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its // Applications pub fn lcp_array_arbitrary(s: &[T], sa: &[usize]) -> Vec { + assert!(s.len() == sa.len()); let n = s.len(); assert!(n >= 1); let mut rnk = vec![0; n]; for i in 0..n { + assert!(sa[i] < n); rnk[sa[i]] = i; } let mut lcp = vec![0; n - 1];