Skip to content

Z Algorithm #5959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed

Z Algorithm #5959

wants to merge 17 commits into from

Conversation

mrinalchauhan
Copy link

The Z Algorithm is an efficient string matching algorithm that computes a Z-array for a given string, which indicates the length of the longest substring starting from each index that matches the prefix of the string.

Key Points:
Z-array: For a string S, Z[i] represents the length of the longest substring starting at index i that is also a prefix of S.
Time Complexity: The algorithm runs in linear time, O(n + m), where n is the length of the text and m is the length of the pattern, making it faster than naive approaches.
Pattern Matching: By combining the pattern and the text into a single string (e.g., pattern$text), the Z-array helps efficiently locate occurrences of the pattern within the text.
Applications: It is widely used in text processing, DNA sequence analysis, and competitive programming for substring searching.
The Z Algorithm is valued for its efficiency and simplicity, allowing for quick implementation in various string matching scenarios.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, please check why PR checks are failing

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.10%. Comparing base (be0b1d5) to head (d4c9664).
Report is 21 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5959      +/-   ##
============================================
+ Coverage     67.43%   69.10%   +1.67%     
- Complexity     4578     4673      +95     
============================================
  Files           620      624       +4     
  Lines         17147    17176      +29     
  Branches       3312     3315       +3     
============================================
+ Hits          11563    11870     +307     
+ Misses         5138     4854     -284     
- Partials        446      452       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

@github-actions github-actions bot added the stale label Nov 25, 2024
Copy link

github-actions bot commented Dec 4, 2024

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

@github-actions github-actions bot closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants