Notice
Recent Posts
Recent Comments
목록KMP (1)
NeuroWhAI의 잡블로그
[C++] KMP 알고리즘 구현
#include #include #include #include using namespace std; // Knuth-Morris-Pratt Algorithm // bush의 앞에서부터 needle의 최초 위치를 찾아 반환합니다. size_t kmp(string_view bush, string_view needle) { const size_t needleLen = needle.length(); const size_t bushLen = bush.length(); // string::find는 패턴 문자열이 비어있을 경우 0을 반환함. if (needleLen == 0) { return 0; } // pi[match] == needle[:match+1]의 최대 동일 접두접미사 길이 vector pi(need..
개발 및 공부/알고리즘
2018. 11. 29. 20:55