public override IEnumerable <object> Solve(TextReader inputStream) { _ = inputStream.ReadInt(); var s = inputStream.ReadLine(); var max = 0; for (int start = 0; start < s.Length; start++) { var zAlgo = ZAlgorithm.SearchAll(s.AsSpan().Slice(start)); for (int i = 0; i < zAlgo.Length; i++) { max = Math.Max(max, Math.Min(i, zAlgo[i])); } } yield return(max); }
public void ZAlgorithmSumomoTest(string input, params int[] expected) { var z = ZAlgorithm.SearchAll(input); Assert.Equal(expected, z); }