leetcode
Data Structures & Algorithms · 143 notes
- Longest Substring Without Repeating Charactershistorical
LeetCode notes on the longest substring without repeating characters.
- Design an LRU Cachehistorical
Design an LRU cache with a map and a doubly linked list, with Go and Java implementations.
- Longest Common Subsequencehistorical
Longest common subsequence using recursion, DFS with memoization, and dynamic programming.
- Letter Combinations of a Phone Numberhistorical
Letter combinations of a phone number using DFS to enumerate combinations.
- Best Time to Buy and Sell Stock with Cooldownhistorical
LeetCode notes on the Best Time to Buy and Sell Stock with Cooldown problem.
- Find All Anagrams in a Stringhistorical
Find all anagrams in a string using brute force and a sliding window with counts.
- Longest Increasing Subsequencehistorical
LeetCode notes on the Longest Increasing Subsequence problem.
- Longest Common Prefixhistorical
Longest common prefix using a brute-force approach, with a trie idea noted.
- Palindromic Substringshistorical
Count palindromic substrings using brute force and center expansion.
- Longest Palindromic Substringhistorical
Longest palindromic substring using brute force and center expansion.
- Find All Numbers Disappeared in an Arrayhistorical
LeetCode notes on finding all disappeared numbers in an array.
- Big Number Additionhistorical
Add large numbers represented as strings by scanning from right to left and carrying.
- Longest Valid Parentheseshistorical
Use a stack to mark matched parentheses, then count the longest consecutive valid interval.
- Remove Invalid Parentheseshistorical
Enumerate whether to keep or remove each character, then keep the longest valid-parentheses results.
- Generate Parentheseshistorical
Generate parentheses using full enumeration with a stack, and pruning based on remaining left/right parentheses.
- Valid Parentheseshistorical
Validate a parentheses sequence using a stack or repeated string replacement.
- Longest Substring Without Repeating Charactershistorical
Find the longest substring without repetition using a brute-force set approach and a sliding window.
- Find First and Last Position of Element in Sorted Arrayhistorical
LeetCode notes on finding the first and last position of an element in a sorted array.
- Evaluate Divisionhistorical
Use weighted union-find to evaluate division relationships between variables.
- Hamming Distancehistorical
Compute the Hamming distance between two integers using bitwise operations.
- Find First and Last Position of Element in Sorted Arrayhistorical
LeetCode notes on finding the first and last position of an element in a sorted array.
- Find the K-th Largesthistorical
Find the K-th largest element in an array using sorting or quicksort partitioning.
- Binary Searchhistorical
Use binary search to find a target value in a sorted ascending integer array.
- Find Minimum in Rotated Sorted Arrayhistorical
LeetCode notes on finding the minimum in a rotated sorted array.
- Find Smallest Letter Greater Than Targethistorical
Find the smallest letter greater than the target in a cyclically ordered character list.
- Queue Reconstruction by Heighthistorical
Sort first and then insert by position to reconstruct a queue described by height and preceding-person counts.
- Largest Numberhistorical
Rearrange non-negative integers so their concatenation forms the largest integer.
- Top K Frequent Elementshistorical
Find the top K frequent elements using frequency counting with sorting or a min-heap.
- Move Zeroeshistorical
Move all zeroes to the end of the array while preserving the relative order of non-zero elements.
- Product of Array Except Selfhistorical
Compute the product of array elements except self using left and right product arrays.
- Sort Colorshistorical
Sort 0, 1, and 2 in place using quicksort, bucket sort, or the move-zeroes idea.
- Search a 2D Matrixhistorical
Search a matrix whose rows and columns are both sorted, starting from the top-right corner.
- Subarray Sum Equals Khistorical
LeetCode notes on the brute-force solution for Subarray Sum Equals K.
- Daily Temperatureshistorical
LeetCode notes on Daily Temperatures with brute force and a monotonic stack.
- Sliding Window Maximumhistorical
LeetCode notes on Sliding Window Maximum using brute force, a priority queue, and a monotonic deque.
- Min Stackhistorical
LeetCode notes on implementing a stack that retrieves the minimum element in constant time.
- Median of Two Sorted Arrayshistorical
LeetCode notes on finding the median of two sorted arrays by merging them.
- Shortest Unsorted Continuous Subarrayhistorical
LeetCode notes on finding the shortest continuous subarray that must be sorted.
- Best Time to Buy and Sell Stockhistorical
LeetCode notes on maximizing profit from one stock transaction.
- Unique Binary Search Treeshistorical
LeetCode notes on counting unique binary search trees with DFS, memoization, and dynamic programming.
- Binary Tree Inorder Traversalhistorical
LeetCode notes on binary tree inorder traversal with recursion and color marking.
- Construct Binary Tree from Preorder and Inorder Traversalhistorical
LeetCode notes on reconstructing a binary tree from preorder and inorder traversals.
- Binary Tree Preorder, Inorder, and Postorder Traversalhistorical
Notes on implementing preorder, inorder, and postorder traversal of a binary tree.
- Convert BST to Greater Treehistorical
LeetCode notes on converting a binary search tree to a Greater Sum Tree.
- Validate Binary Search Treehistorical
LeetCode notes on validating a binary search tree with inorder traversal.
- Flatten Binary Tree to Linked Listhistorical
LeetCode notes on flattening a binary tree into a linked list in preorder.
- Lowest Common Ancestor of a Binary Treehistorical
LeetCode notes on finding the lowest common ancestor in a binary tree.
- Lowest Common Ancestor Nodehistorical
Notes on finding the lowest common ancestor of two nodes in a binary tree.
- Sum Root to Leaf Numbershistorical
LeetCode notes on summing all numbers formed by root-to-leaf paths.
- Serialize and Deserialize Binary Treehistorical
LeetCode notes on Serialize and Deserialize Binary Tree.
- Binary Tree Zigzag Level Order Traversalhistorical
LeetCode notes on Binary Tree Zigzag Level Order Traversal.
- Remove Duplicates from Sorted List IIhistorical
LeetCode notes on Remove Duplicates from Sorted List II.