Practical Implementations of Iterative Deepening A* Search
Segment Rotation Optimization
When solving permutation puzzles that require rearranging contiguous segments within a fixed array, the branching factor can grow exponentially. For an array of length $n$, selecting a segment of length $i$ yields $n-i+1$ starting positions and $n-i$ insertion points. Accounting for symmetry (forward vs. backward m ...
Posted on Tue, 12 May 2026 15:42:03 +0000 by foochuck
Backtracking for Combination Sum, Combination Sum II, and Palindrome Partitioning
39. Combination Sum
Problem: https://leetcode.cn/problems/combination-sum/description/
Find all unique combinations of candidates where the chosen numbers sum to target. The same number may be used a unlimited number of times.
class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int targ ...
Posted on Sun, 10 May 2026 15:26:59 +0000 by Jedi Legend
Combination Sum II - Handling Duplicate Elements in Backtracking
Given an array of integers candidates and a target value target, find all unique combinations in candidates where the numbers sum to target.
Key constraints:
Each number can only be used once in each combination.
All numbers (including the target) are positive integers.
The result set must not contain duplicate combinations.
Examples
Example ...
Posted on Sun, 10 May 2026 11:27:21 +0000 by smilley654
Backtracking with Element Tracking for Deduplication
Problem 491: Non-decreasing Subsequences
Given an integer array nums, return all the different non-decreasing subsequences that have atleast two elements. The answer can be in any order. When two integers are equal, this counts as a valid increasing sequecne.
Example 1:
Input: nums = [4,6,7,7]
Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7 ...
Posted on Fri, 08 May 2026 23:26:45 +0000 by mcccy005
Efficient Solutions for Word Search II Problem
Given an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.
1. Trie with DFS
Build a trie from the given wor ...
Posted on Thu, 07 May 2026 19:06:04 +0000 by Lassie
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