Dp

17 articles

dsa2 min read

Unique Binary Search Trees II

Generate all structurally unique BSTs with values 1 to n using divide and conquer with memoization.

Read →
dsa2 min read

House Robber III

Maximize robbery from a tree-structured neighborhood where adjacent (parent-child) nodes cannot both be robbed.

Read →
dsa3 min read

Kth Ancestor of a Tree Node

Find the Kth ancestor of any tree node in O(log k) per query using binary lifting (sparse table DP).

Read →
dsa2 min read

Unique Binary Search Trees

Count the number of structurally unique BSTs with n nodes using Catalan numbers and DP.

Read →