Dynamic Programming Approaches for Palindrome String Problems
Counting Palindromic Substrings
This section addresses the problem of counting all palindromic substrings within a given string, similar to LeetCode problem 647.
Problem Description
Given a string s, determine and return the total count of palindromic substrings. A substring is a contiguous sequence of charcaters. A palindromic string reads the ...
Posted on Tue, 14 Jul 2026 16:19:33 +0000 by mdgalib
Palindrome Linked List Detection
Problem Description
Given the head of a singly linked list, determine if the list is a palindrome. Return true if it is, otherwise return false.
An optimal solution achieves O(n) time complexity and O(1) space complexity by combining a fast-slow pointer approach to find the middle node with a reversal of the latter half of the list.
Algorithm O ...
Posted on Thu, 18 Jun 2026 17:48:25 +0000 by jamesnkk
Backtracking Algorithms for Combination Sum and Palindrome Partitioning
Combination Sum
The objective is to find all unique combinations from a list of candidate numbers that sum up to a given target. Each number may be used multiple times.
The solution uses recursive backtracking with the following approach:
Parameters include the candidate array, target value, current combination, and results collection
Terminat ...
Posted on Fri, 05 Jun 2026 17:01:53 +0000 by abushahin
Enumerating Palindromic Dates Efficiently for NOIP Popularization Group 2016
Online Judge Reference:
http://ybt.ssoier.cn:8088/problem_show.php?pid=1974
Core Concepts
The problem requires identifying dates that are both valid calendar dates and palindromes. A naive approach iterates through every 8-digit number between the start and end dates, resulting in a complexity of O(10^8). While this might pass, it is computat ...
Posted on Sat, 30 May 2026 23:30:16 +0000 by greg252
BFS on Parity-Based Reachability for a Single 1 in a Binary String
Spinning Around
Given a binary string (S) of length (n) with exactly one 1. In each operation, you can reverse a substring of length (k). For each position (i), find the minimum number of operations to move the 1 to position (i). Some positions are forbidden and cannot hold the 1 during the process. If no such number exists, output (-1).
(n \le ...
Posted on Fri, 15 May 2026 16:47:23 +0000 by Matt Kindig
Minimum Steps to Remove Palindromic Subsequences
Given a string s consisting exclusively of the characters 'a' and 'b', the objective is to determine the minimum number of steps required to make the string empty. In each operation, you are allowed to delete a palindromic subsequence from s.
A subsequence is defined as a sequence that can be derived from another sequence by deleting zero or m ...
Posted on Sun, 10 May 2026 18:08:29 +0000 by dkoolgeek
Solving Common Linked List Problems: Kth-from-End, Palindrome Check, and Intersection Detection
Finding the Kth Node from the End of a Linked List
To locate the kth node from the end efficient, use two pointers—fast and slow. Advance the fast pointer by k steps first. Then move both pointers forward until fast reaches the end. At this point, slow will be pointing to the desired node.
int kthToLast(struct ListNode* head, int k) {
struc ...
Posted on Sat, 09 May 2026 12:56:21 +0000 by csimms
Finding the Longest Palindromic Substring Using Dynamic Programming
Given a string text, the objective is to locate longest contiguous substring that reads the same forward and backward.
Constraints:
1 <= text.length <= 1000
text consists of alphanumeric English characters only.
Dynamic Programming Approahc
1. State Definition
Define a 2D table is_palindrome[i][j] where i and j are indices. The value i ...
Posted on Thu, 07 May 2026 10:45:37 +0000 by Pnop
Backtracking Problems: Combination Sum and Palindrome Partitioning
39. Combination Sum
The key insight for this problem is understanding how elements can be reused during the search process. When recursively exploring combinations, each element can be selected multiple times since we continue searching from the current index rather than moving to the next one.
Consider the tree structure: after selecting an el ...
Posted on Thu, 07 May 2026 06:45:14 +0000 by rachelk
Finding the Longest Palindromic Substring in Linear Time Using Manacher's Algorithm
Problem Statement
Given a string of length (n), find the length of the longest palindromic substring where (n \le 10^5).
Brute-Force Approach
A straightforward method involves iterating through each position as a potential center and expanding outward in both directions to check for palindromes. Taking the maximum length among all centers yield ...
Posted on Thu, 07 May 2026 03:39:19 +0000 by mdomel