TheAlgorithms / C-Plus-Plus

Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
https://thealgorithms.github.io/C-Plus-Plus
MIT License
30.08k stars 7.1k forks source link

[BUG] KMP algorithm #2712

Closed Yancey2023 closed 2 weeks ago

Yancey2023 commented 2 weeks ago

Description

For strings/knuth_morris_pratt.cpp: if pattern is empty, it should immediately return true, otherwise pattern[k] will access out of bounds.

Expected behavior

.

Actual behavior

.

Steps to reproduce

No response

Context

.

Additional information

No response