Tags

Palindrome

Palindrome

1 lesson
5 problems
1 question bank

palindrome

Algorithms

1 lesson

String Algorithms

Advanced

70 min

2 prereqs

Naive substring search compares the pattern against every position in the text, restarting from scratch on each mismatch, for `O(n * m)` worst-case time. KMP, by precomputing where to resume after a mismatch, never restarts. The text pointer moves forward strictly monotonically, the pattern pointer is corrected by a failure function, and the whole search runs in `O(n + m)`. That single insight defines a family of linear-time string algorithms that power editors, search engines, and bioinformatics pipelines. **String Algorithms** covers that family. KMP teaches you to build the failure function (prefix function) and use it to skip redundant comparisons. The Z algorithm offers an alternative `O(n)` framework based on the Z-array. Rabin-Karp introduces rolling hashes for multi-pattern search and is the backbone of plagiarism detection. Manacher's algorithm finds the longest palindromic substring in linear time using a clever transform with separators. Aho-Corasick generalizes KMP to multiple patterns simultaneously by adding failure links to a trie, producing a finite automaton that scans the text once. In **Arrays & Strings**, you treated strings as arrays of characters with `O(1)` indexed access. **Hash Map (Dictionary) Basics** gave you the `O(1)` lookup used by Rabin-Karp. This lesson layers algorithmic structure on top of those primitives. Next, **Pattern Matching Algorithms** extends the toolkit with Boyer-Moore, DFA-based matching, and 2D pattern search.

Not Started

0%

Algorithms
Strings
String Matching
KMP Algorithm
Rabin-Karp Algorithm
Z-Algorithm
Rolling Hash
Palindrome
Advanced
Premium

Practice Problems

5 problems

Palindrome Number

Free
Not Started
Easy

Determine whether an integer is a palindrome without converting it to a string, by reversing half of the number and comparing.

Mathematics
Palindrome
Beginner

348

6

Valid Palindrome

Free
Not Started
Easy

Determine if a string is a palindrome, considering only alphanumeric characters and ignoring cases.

Two Pointers
Strings
Palindrome
Beginner

284

5

Longest Palindromic Substring

Not Started
Medium

Given a string, return the longest substring that reads the same forwards and backwards.

Strings
Dynamic Programming
Expand Around Center
Palindrome
Algorithms
Intermediate

236

1

Palindrome Partitioning

Not Started
Medium

Given a string, partition it such that every substring of the partition is a palindrome. Return all possible palindrome partitions.

Strings
Backtracking
Recursion
Palindrome
Dynamic Programming
Algorithms
Intermediate

734

21

Palindromic Substrings

Not Started
Medium

Given a string, return the number of substrings that are palindromes. Each unique start-end position counts as a different substring even if the characters are the same.

Strings
Dynamic Programming
Expand Around Center
Palindrome
Algorithms
Intermediate

770

19