Stack is used to address LIFO problems while queue for FIFO problems. The concept of data structure is…
An advanced Tree DFS that combines the technique of Path Sum III & Diameter of Binary Tree.
Stack / Queue provides similar effect with DFS as it controls the returning sequence of temporary output, but requires less memory space.
Description
Matrix problem that leverages dp.
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1])…
m x n
grid[0][0]
grid[m - 1][n - 1]
A DFS problem that requires special design.
A sliding window problem similar with Longest Repeating Character Replacement while requires more intricate technique.
Given two strings s and t of lengths m and n respectively, return the minimum window…
s
t
m
n
Use in place modification to locate target in array.
Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice…
nums
[1, n]
Similar with Climbing Stairs that turns sum into max.
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each…
A rarely seen pattern of two pointers.
Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.
arr
k
x
An extension of Reverse Linked List. The essence is leveraging decrease and conquer.