Skip to content

Instantly share code, notes, and snippets.

@rishi93
rishi93 / test1.cpp
Last active October 4, 2022 03:31
Pattern Searching - KMP algorithm
#include <iostream>
#include <string>
using namespace std;
void kmp_search(string haystack, string needle){
int N, M, i, j, len;
N = haystack.length();
M = needle.length();
// Longest Proper Suffix array or Partial match Table
@YDrall
YDrall / kmp.cpp
Created August 18, 2015 16:10
c++ implementation of kmp string matching algorithm.
#include<iostream>
#include<string>
using namespace std;
int *pre_kmp(string pattern)
{
int size = pattern.size();
int *pie=new int [size];
pie[0] = 0;