Java icon indicating copy to clipboard operation
Java copied to clipboard

Z Algorithm

Open mrinalchauhan opened this issue 1 year ago • 1 comments

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.

mrinalchauhan avatar Oct 23 '24 20:10 mrinalchauhan

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 25 '24 20:10 codecov-commenter

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[bot] avatar Nov 25 '24 00:11 github-actions[bot]

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[bot] avatar Dec 04 '24 00:12 github-actions[bot]