Split Array Largest Sum — Binary Search on Answer
Minimize the largest subarray sum when splitting into k parts using binary search on the possible answer range.
webcoderspeed.com
17 articles
Minimize the largest subarray sum when splitting into k parts using binary search on the possible answer range.
Find the longest arithmetic subsequence using dp[i][diff] = length ending at index i with given difference.
Maximize score jumping through an array with window k by combining DP with a monotonic decreasing deque.
Generate all structurally unique BSTs with values 1 to n using divide and conquer with memoization.
Maximize robbery from a tree-structured neighborhood where adjacent (parent-child) nodes cannot both be robbed.
Find the Kth ancestor of any tree node in O(log k) per query using binary lifting (sparse table DP).
Count the number of structurally unique BSTs with n nodes using Catalan numbers and DP.
Compare backtracking and DP approaches for subset sum: when to use each, conversion to knapsack, and bitset optimization.
Apply probability theory and expected value DP to competitive programming: dice problems, random walks, and geometric distribution.
Compute shortest paths between all pairs of vertices using Floyd-Warshall's O(V³) DP. Handles negative weights and detects negative cycles.
Compute single-source shortest paths in graphs with negative weight edges using Bellman-Ford. V-1 relaxation passes detect negative cycles on the Vth pass.
Count the number of shortest paths from source to destination using modified Dijkstra that tracks both minimum distance and path count simultaneously.
Find the longest path in a directed acyclic graph using DFS with memoisation. Since cycles are absent, DFS never revisits nodes, making top-down DP straightforward.
Find the longest common substring between two strings. DP approach O(nm), binary search + rolling hash O((n+m) log(n+m)).
Core string DP patterns: edit distance (Wagner-Fischer), longest common subsequence, interleaving strings, and regular expression matching.
Comprehensive palindrome problem coverage: valid palindrome check, longest palindromic substring (three methods), count palindromic substrings, and palindrome partitioning.
Return all ways to segment a string into dictionary words. Combines DP validity check with DFS+memo backtracking to avoid TLE on valid inputs.