Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 329 Bytes

File metadata and controls

17 lines (12 loc) · 329 Bytes

Problem 3: Z-Algorithm

Problem Statement

Compute the Z-array where Z[i] is the length of the longest substring starting at i that matches a prefix.

Input Format

  • A string s.

Output Format

  • The Z-array.

Constraints

  • 1 <= len(s) <= 10^5

Example

Input: s="aabxaab"
Output: [7, 1, 0, 0, 3, 1, 0]