CS Theory
Path Sum III: Count All Paths That Sum to Target
Solve the Path Sum III problem by counting all downward paths in a binary tree that sum to a target value. Use nested recursion to explore every possible starting point and count valid paths from each.
February 5, 2026
Path Sum in Binary Trees
Check if a binary tree has a root-to-leaf path where node values sum to a target. Two approaches: recursive accumulation or subtraction method. The key insight is identifying true leaf nodes with no children.
February 5, 2026
Powerful Integers: A Brute Force Optimization Lesson
Solving the Powerful Integers problem through brute force optimization. Learn how to reduce computational complexity by choosing the right enumeration strategy and using efficient data structures like unordered_set for O(1) operations.
February 5, 2026
Powers of N: Two Ways to Check
How to determine if a number is a power of base i? You can divide repeatedly or use logarithms. The first method works through continuous division by the base. The second uses the change of base formula to check if the result is an integer.
February 5, 2026
Queries on a Permutation With Key
Solve permutation queries by tracking element positions and moving accessed elements to front. Two approaches: brute force O(n²) and Fenwick tree optimization O(n log n) for efficient prefix sum updates.
February 5, 2026
Reconstructing Binary Trees from Traversal Sequences
Learn how to rebuild binary trees from different combinations of traversal sequences like preorder and inorder or inorder and postorder traversals using divide-and-conquer recursion.
February 5, 2026
Regular Expression Matching Demystified
A practical guide to implementing wildcard and regular expression matching algorithms. We walk through two classic problems: wildcard matching with ? and * operators, and full regex matching with . and * patterns using dynamic programming approaches.
February 5, 2026
Reverse Bits with Group Reversals
A bit manipulation technique that reverses the order of bits in a 32-bit integer by swapping groups of bits in multiple passes from large chunks down to individual bits.
February 5, 2026
Search in Rotated Sorted Arrays
Binary search solutions for rotated sorted arrays with and without duplicates. Learn how to handle rotation points and duplicate elements when searching in modified sorted arrays.
February 5, 2026
Smallest Subsequence with Distinct Characters
Find the lexicographically smallest subsequence containing distinct characters from an alphabetic string. This greedy algorithm removes duplicate characters while maintaining order to achieve optimal results in linear time.
February 5, 2026