---
id: string-search
title: "String Searching"
author: Benjamin Qi
prerequisites:
 - Silver - Depth First Search
description: Knuth-Morris-Pratt and Z Algorithms (and a few more related topics).
frequency: 1
---

export const metadata = {
  problems: {
    sample: [
      new Problem("YS", "Set XOR-Min", "set_xor_min", "Easy", false, [], ""),
    ],
    Z: [
      new Problem("YS", "Z Algorithm", "zalgorithm", "Easy", false, [], ""),
      new Problem("CF", "Concatenation with Intersection", "contest/1313/problem/E", "Hard", false, [], "")
    ],
    pal: [
      new Problem("ojuz", "Palindrome", "APIO14_palindrome", "Easy", false, [], ""),
    ]
  }
};

## General

<resources>
  <resource source="CPC" title="11 - Strings" url="11_strings">String Matching, KMP, Tries</resource>
</resources>

# Single String

## KMP

<resources>
  <resource source="cp-algo" title="Prefix Function" url="prefix-function.html"></resource>
  <resource source="PAPS" title="14.2 - String Matching"></resource>
  <resource source="GFG" title="KMP Algorithm" url="searching-for-patterns-set-2-kmp-algorithm"></resource>
  <resource source="TC" title="String Searching" url="introduction-to-string-searching-algorithms"></resource>
</resources>


## Z Algorithm

<problems-list problems={metadata.problems.Z} />

<resources>
  <resource source="cp-algo" title="Z Function" url="z-function.html"></resource>
  <resource source="CPH" title="26.4 - Z-algorithm"></resource>
  <resource source="CF" title="Z Algorithm" url="blog/entry/3107"></resource>
</resources>

## Manacher

<resources>
  <resource source="HR" title="Manacher's Algorithm" url="https://www.hackerrank.com/topics/manachers-algorithm"></resource>
  <resource source="CF" title="adamant - Manacher's algorithm and code readability" url="blog/entry/12143" starred>shorter code</resource>
  <resource source="cp-algo" title="Manacher's Algorithm" url="string/manacher.html"></resource>
</resources>

# Multiple Strings

## Tries

<problems-list problems={metadata.problems.sample} />

<resources>
  <resource source="CPH" title="26.2"></resource>
  <resource source="CF" title="Algorithm Gym" url="blog/entry/15729"></resource>
  <resource source="PAPS" title="14.1 - Tries"></resource>
</resources>

## Aho-Corasick

<resources>
  <resource source="cp-algo" title="Aho Corasick" url="string/aho_corasick.html"></resource>
  <resource source="CF" title="adamant - Aho-Corasick" url="blog/entry/14854"></resource>
  <resource source="GFG" title="Aho-Corasick for Pattern Searching" url="aho-corasick-algorithm-pattern-searching"></resource>
</resources>

## Palindromic Tree

<problems-list problems={metadata.problems.pal} />

<resources>
  <resource source="CF" title="adamant - Palindromic Tree" url="blog/entry/13959"></resource>
</resources>

DMOJ thing
