Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Maintain and match against a library of classic dynamic programming patterns. Provides pattern matching, template code generation, variant detection, and problem-to-pattern mapping for DP problems.
.claude/skills/a5c-ai-dp-pattern-library/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 58% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 69% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 135% | 0% |
| case-01 | ✗→✗ | = Same ✗ | 70% | 0% |
| case-04 | ✗→✗ | = Same ✗ | 74% | 0% |
A specialized skill for dynamic programming pattern recognition, matching problems to known DP patterns, generating template code, and providing optimization guidance for DP solutions.
Assist with dynamic programming by:
| Pattern | State | Transition | Example Problems | |---------|-------|------------|------------------| | Fibonacci | dpi] = answer for position i | dpi] = dpi-1] + dpi-2] | Climbing Stairs, House Robber | | Min/Max Path | dpi] = best answer ending at i | dpi] = opt(dpj]) + cost(j,i) | Minimum Path Sum | | Counting | dpi] = ways to reach state i | dpi] = sum(dpj]) | Unique Paths, Decode Ways | | LIS | dpi] = LIS ending at i | dpi] = max(dpj]) + 1 where j < i, aj] < ai] | Longest Increasing Subsequence |
| Pattern | State | Example Problems | |---------|-------|------------------| | Edit Distance | dpi]j] = distance for s10..i], s20..j] | Edit Distance, One Edit Distance | | LCS | dpi]j] = LCS of s10..i], s20..j] | Longest Common Subsequence | | Palindrome | dpi]j] = is si..j] palindrome | Longest Palindromic Substring | | Regex Match | dpi]j] = s0..i] matches p0..j] | Regular Expression Matching |
| Variant | State | Transition | |---------|-------|------------| | 0/1 Knapsack | dpi]w] = max value with items 0..i, capacity w | dpi]w] = max(dpi-1]w], dpi-1]w-wti]] + vali]) | | Unbounded | dpw] = max value with capacity w | dpw] = max(dpw], dpw-wti]] + vali]) | | Bounded | dpi]w] = max value with limited items | Use binary representation or deque | | Subset Sum | dpi]s] = can reach sum s with items 0..i | dpi]s] = dpi-1]s] or dpi-1]s-ai]] |
| Pattern | State | Example Problems | |---------|-------|------------------| | Path Count | dpi]j] = ways to reach (i,j) | Unique Paths, Unique Paths II | | Path Min/Max | dpi]j] = best path to (i,j) | Minimum Path Sum | | Multi-path | dpi]j]k]l] = two paths simultaneously | Cherry Pickup |
| Pattern | State | Example Problems | |---------|-------|------------------| | MCM | dpi]j] = cost for range i,j] | Matrix Chain Multiplication | | Burst | dpi]j] = max coins from balloonsi..j] | Burst Balloons | | Merge | dpi]j] = cost to merge range i,j] | Minimum Cost to Merge Stones |
| Pattern | State | Example Problems | |---------|-------|------------------| | Subtree | dpv] = answer for subtree rooted at v | Binary Tree Maximum Path Sum | | Rerooting | dpv] = answer when v is root | Sum of Distances in Tree | | Parent-Child | dpv]0/1] = answer with constraint | House Robber III |
| Pattern | State | Example Problems | |---------|-------|------------------| | TSP | dpmask]last] = min cost visiting mask cities ending at last | Traveling Salesman Problem | | Assignment | dpmask] = min cost assigning tasks to subset | Task Assignment | | SOS | dpmask] = sum over subsets | Subset Sum over Subsets |
bash# Match problem to DP pattern dp-pattern-library match --problem "Given an array of integers, find the longest increasing subsequence" # Output: # Pattern: Linear DP - Longest Increasing Subsequence (LIS) # State: dp[i] = length of LIS ending at index i # Transition: dp[i] = max(dp[j] + 1) for all j < i where arr[j] < arr[i] # Time: O(n^2) naive, O(n log n) with binary search # Space: O(n)
bash# Generate template code dp-pattern-library template --pattern "lis" --language python # Output: def lengthOfLIS(nums): if not nums: return 0 n = len(nums) # dp[i] = length of LIS ending at index i dp = [1] * n for i in range(1, n): for j in range(i): if nums[j] < nums[i]: dp[i] = max(dp[i], dp[j] + 1) return max(dp)
bash# Get optimization recommendations dp-pattern-library optimize --pattern "lis" # Output: # Current: O(n^2) time, O(n) space # Optimizations: # 1. Binary Search: O(n log n) time # - Maintain sorted list of smallest tail elements # - Binary search for insertion point # 2. Segment Tree: O(n log n) time # - For coordinate compression + range max query
json{ "match": { "pattern": "Linear DP - LIS", "confidence": 0.95, "category": "linear", "variants": ["LIS", "LDS", "LNDS"] }, "state": { "description": "dp[i] = length of LIS ending at index i", "dimensions": 1, "meaning": "LIS length ending at position i" }, "transition": { "formula": "dp[i] = max(dp[j] + 1) for j < i, arr[j] < arr[i]", "baseCase": "dp[i] = 1 for all i", "order": "left to right" }, "complexity": { "time": "O(n^2)", "space": "O(n)", "optimized": { "time": "O(n log n)", "technique": "binary search on patience sort" } }, "template": { "python": "...", "cpp": "...", "java": "..." }, "similarProblems": [ "Longest Increasing Subsequence", "Number of Longest Increasing Subsequence", "Russian Doll Envelopes", "Maximum Length of Pair Chain" ] }
This skill enhances:
dp-pattern-matching - Core pattern matching workflowdp-state-optimization - State space optimizationdp-transition-derivation - Deriving transitionsleetcode-problem-solving - DP problem identificationclassic-dp-library - Building a personal DP library| Indicator | Likely Pattern | |-----------|----------------| | "maximum/minimum" + "subarray/subsequence" | Linear DP | | "number of ways" | Counting DP | | "can reach/achieve" | Boolean DP | | "edit/transform string" | String DP | | "merge/combine intervals" | Interval DP | | "tree/subtree" | Tree DP | | "select subset" + small n | Bitmask DP | | "count numbers with property" | Digit DP | | "items + capacity" | Knapsack |
| Error | Cause | Resolution | |-------|-------|------------| | NO_PATTERN_MATCH | Problem doesn't fit known patterns | Consider greedy or other approaches | | AMBIGUOUS_MATCH | Multiple patterns could apply | Provide more problem details | | COMPLEX_STATE | State too complex for templates | Manual state design needed |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 13,798 | 11,229 | -19% | 1 | 1 | 0% | 2,823 | 4,798 | +70% | 0 | 0 | — |
case-02 | pass→pass | 9,665 | 9,380 | -3% | 1 | 1 | 0% | 1,916 | 4,511 | +135% | 0 | 0 | — |
case-03 | fail→pass | 12,423 | 12,004 | -3% | 1 | 1 | 0% | 3,334 | 5,270 | +58% | 0 | 0 | — |
case-04 | fail→fail | 12,453 | 10,049 | -19% | 1 | 1 | 0% | 2,674 | 4,658 | +74% | 0 | 0 | — |
case-05 | fail→fail | 11,329 | 14,421 | +27% | 1 | 1 | 0% | 2,187 | 4,896 | +124% | 0 | 0 | — |
case-06 | fail→fail | 6,528 | 10,392 | +59% | 1 | 1 | 0% | 1,309 | 4,729 | +261% | 0 | 0 | — |
case-07 | fail→fail | 6,498 | 5,993 | -8% | 1 | 1 | 0% | 1,268 | 3,644 | +187% | 0 | 0 | — |
case-08 | fail→fail | 12,297 | 7,654 | -38% | 1 | 1 | 0% | 2,476 | 4,124 | +67% | 0 | 0 | — |
case-09 | fail→fail | 9,116 | 11,970 | +31% | 1 | 1 | 0% | 1,745 | 4,405 | +152% | 0 | 0 | — |
case-10 | fail→fail | 8,553 | 10,443 | +22% | 1 | 1 | 0% | 1,437 | 4,191 | +192% | 0 | 0 | — |
case-11 | fail→fail | 7,915 | 6,636 | -16% | 1 | 1 | 0% | 1,438 | 3,937 | +174% | 0 | 0 | — |
case-12 | fail→fail | 10,486 | 12,081 | +15% | 1 | 1 | 0% | 2,320 | 5,089 | +119% | 0 | 0 | — |
case-13 | fail→fail | 10,555 | 12,219 | +16% | 1 | 1 | 0% | 2,169 | 5,045 | +133% | 0 | 0 | — |
case-14 | fail→fail | 11,351 | 8,613 | -24% | 1 | 1 | 0% | 2,337 | 4,303 | +84% | 0 | 0 | — |
case-15 | fail→fail | 7,996 | 11,876 | +49% | 1 | 1 | 0% | 1,586 | 4,948 | +212% | 0 | 0 | — |
case-16 | fail→fail | 12,978 | 10,696 | -18% | 1 | 1 | 0% | 2,180 | 4,542 | +108% | 0 | 0 | — |
case-17 | fail→fail | 6,233 | 4,827 | -23% | 1 | 1 | 0% | 1,424 | 3,514 | +147% | 0 | 0 | — |
case-18 | fail→fail | 9,735 | 9,577 | -2% | 1 | 1 | 0% | 2,039 | 4,571 | +124% | 0 | 0 | — |
case-19 | fail→fail | 9,704 | 9,992 | +3% | 1 | 1 | 0% | 1,941 | 4,560 | +135% | 0 | 0 | — |
case-20 | fail→pass | 14,072 | 13,814 | -2% | 1 | 1 | 0% | 3,168 | 5,359 | +69% | 0 | 0 | — |
case-21 | fail→fail | 12,602 | 10,330 | -18% | 1 | 1 | 0% | 3,023 | 4,742 | +57% | 0 | 0 | — |
case-22 | fail→fail | 16,902 | 12,484 | -26% | 1 | 1 | 0% | 3,544 | 5,267 | +49% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.