動的計画法

複雑な最適化問題を重複する部分問題に分解して解決します。フィボナッチ数列、最長共通部分列、ナップサック問題、行列連鎖乗算などの古典的な問題を通じて、メモ化とボトムアップアプローチをマスターします。動的計画法が指数時間の解を多項式時間アルゴリズムに変換する方法を学びます。

9 アルゴリズム

Matrix Chain Multiplication

Advanced

Finds the optimal way to parenthesize a chain of matrices to minimize the number of scalar multiplications. Classic dynamic programming problem from CLRS Chapter 15.

O(n³)
O(n²)
dynamic-programmingoptimization
Start Learning

フィボナッチ数列(動的計画法)

Beginner

動的計画法を使用して冗長な計算を避けながらフィボナッチ数を効率的に計算します。メモ化の力を示し、指数時間の再帰的解を線形時間アルゴリズムに変換します。動的計画法の概念への古典的な入門です。

O(n)
O(n)
dynamic-programmingmemoization
Start Learning

最長共通部分列(LCS)

Intermediate

2つの列に同じ順序で存在する最長の部分列を見つけます。動的計画法を使用して解テーブルを構築します。DNA配列アライメント、ファイル差分ツール(diff)、盗作検出などの応用があります。

O(m × n)
O(m × n)
dynamic-programmingstrings
Start Learning

Edit Distance (Levenshtein)

Intermediate

Dynamic programming algorithm that calculates the minimum number of single-character edits (insertions, deletions, substitutions) required to transform one string into another. Fundamental in spell checking, DNA sequence alignment, and natural language processing.

O(m × n)
O(m × n)
dynamic-programmingstrings
Start Learning

0/1 Knapsack Problem

Intermediate

Classic dynamic programming problem where you must select items with given weights and values to maximize total value while staying within a weight capacity. Each item can only be taken once (0/1). Applications include resource allocation, portfolio optimization, and cargo loading.

O(n × W)
O(n × W)
dynamic-programmingoptimization
Start Learning

Longest Increasing Subsequence

Intermediate

Find the longest subsequence where all elements are in increasing order. Classic DP problem.

O(n log n)
O(n)
dynamic-programmingbinary-search
Start Learning

Kadane's Algorithm (Maximum Subarray)

Intermediate

Elegant dynamic programming algorithm that finds the contiguous subarray with maximum sum in O(n) time. Combines greedy and DP principles by deciding at each step whether to extend the current subarray or start a new one. Essential for stock profit optimization, signal processing, and understanding DP optimization techniques.

O(n)
O(1)
dynamic-programminggreedy
Start Learning

Coin Change Problem

Intermediate

Classic dynamic programming problem that finds the minimum number of coins needed to make a target amount. Demonstrates optimal substructure where the solution depends on solutions to smaller amounts. Widely applied in financial systems, vending machines, and resource allocation optimization.

O(amount × coins)
O(amount)
dynamic-programmingoptimization
Start Learning

Palindrome Partitioning

Advanced

Dynamic programming problem that finds the minimum number of cuts needed to partition a string into palindromic substrings. Uses DP to precompute which substrings are palindromes, then finds optimal cuts. Applications include text segmentation, DNA sequence analysis, and string optimization problems.

O(n²)
O(n²)
dynamic-programmingstrings
Start Learning

💡 学習のヒント

基礎を固めるために初級レベルのアルゴリズムから始め、中級および上級のトピックに進んでください。各アルゴリズムには、インタラクティブな可視化、複雑度分析、複数の言語でのコード例が含まれています。