Skip to content

Conversation

@nayan458
Copy link

@nayan458 nayan458 commented Oct 1, 2025

Summary

This PR introduces the Rabin-Karp algorithm for substring search in Java.
It includes:

  • RabinKarpSubstringSearchSnippet class with:
    • rabinKarpSearch method to find the first occurrence of a substring.
    • Efficient hash computation using a large prime.
    • Sliding window hash recalculation.
    • Substring equality check for collision handling.
  • RabinKarpSubstringSearchSnippetTest class similar to the tests in KMP for testing and comparisons.
  • A ready-to-use README.md snippet documenting usage.
  • BUILD SUCCESSFUL

Benefits

  • Provides an alternative to KMP for substring search.
  • Suitable for multiple pattern searches with rolling hash.
  • Modular, clean, and well-documented code for educational and production use.

Notes

  • Uses 1_000_000_007 as prime to reduce hash collisions.
  • Designed for clarity and maintainability.

@nayan458
Copy link
Author

nayan458 commented Oct 2, 2025

@iluwatar The GitHub Actions build failed due to a missing SonarCloud token (SONAR_TOKEN).
The code compiles and all tests pass locally, so the failure is related to CI configuration rather than the code changes.

Could you please configure SONAR_TOKEN in the repository secrets for SonarCloud analysis? 🙏

@stale
Copy link

stale bot commented Nov 1, 2025

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.

@stale stale bot added the status: stale label Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant