Fading Coder

One Final Commit for the Last Sprint

Algorithmic Strategies for Competitive Programming Challenges

Composite Coloring with Bounded Prime Factors Problem Specification Given a sequence of composite integers $a$ of length $n$, assign colors such that the greatest common divisor of all numbers sharing the same color exceeds $1$. The total number of distinct colors must not exceed $11$. Constraints:...

Dynamic Programming for Unbounded Knapsack Problems: Coin Change, Combination Sum, and Stair Climbing

Unbounded Knapsack Fundamentals In the unbounded knapsack problem, each item can be used an unlimited number of times, unlike the 0/1 knapsack where each item is used at most once. This difference requires two key implementation changes: When iterating through the knapsack capacity, we must iterate...

Implementing Linear Dynamic Programming in Python

Linear dynamic programming is a specific approach within dynamic programming used to solve problems with a linear structure. In this paradigm, the states of the problem exhibit a linear relationship, and information is typically stored and transferred using a one-dimensional array. It is commonly ap...

Finding the Longest Non-Decreasing Subsequence in a Directed Acyclic Graph Using Dynamic Programming and Topological Sort

Problem Description You are given a directed acyclic graph (DAG) with n nodes and m edges. The nodes are numbered from 1 to n. Each node i has an associated weight w_i. For any path in the graph, you can obtain a sequence of node weights based on the order of traversal. The goal is to find the maxim...