Articles tagged with C++
- Make Sum Divisible by P - Two Sum logic on prefix mod, published 2024-10-06
- LRU Cache - Implementing an LRU Cache in C++: Step-by-Step Guide with Code Examples, published 2024-07-11
- Most Frequent Subtree Sum - Plain and simple DFS, published 2024-05-08
- Greatest Common Divisor Traversal - Prime graph connectivity, published 2024-02-25
- Find All People With Secret - UnionFind and Min-Heap solutions, published 2024-02-25
- Cherry Pickup II - Clear concise 2D DP, published 2024-02-11
- Maximum Good Subarray Sum - Prefix Sum + HashMap, published 2024-02-05
- Partition Array for Maximum Sum - Top down and bottom up DP, published 2024-02-03
- Number of Submatrices That Sum to Target - Subarray target sum properly explained, published 2024-01-28
- Out of Boundary Paths - DFS + Recursive Memoization, published 2024-01-26
- Pseudo-Palindromic Paths in a Binary Tree - Simple DFS with palindrome test at leaves, published 2024-01-24
- Insert Delete GetRandom O(1) - Swap with last element, published 2024-01-16
- Leaf-Similar Trees - Leaf Iterator, published 2024-01-09
- Minimum Difficulty of a Job Schedule - Simple concise code for top-down DP with intuition, published 2023-12-30
- Partition Labels - Greedy logic, published 2023-12-23
- Minimum Cost to Make Array Equalindromic - Check one palindrome on each side of median, published 2023-12-18
- Count of Smaller Numbers After Self - MergeSort based concise solution, published 2023-12-08
- Largest Submatrix With Rearrangements - Permute histogram bars to maximize area, published 2023-11-26
- Diagonal Traverse II - Short and clean five lines of code using TreeMap, published 2023-11-22
- Bus Routes - BFS solution with intuition, published 2023-11-12
- Design Graph With Shortest Path Calculator - Dijkstra and Floyd-Warshall both solutions with intuition, published 2023-11-11
- Restore the Array From Adjacent Pairs - Create graph and run DFS, published 2023-11-10
- Count Nodes Equal to Average of Subtree - Simple recursion in O(n) TC, published 2023-11-02
- Find Mode in Binary Search Tree - Two solutions: O(h) space and O(1) space, published 2023-11-01
- Count Vowels Permutation - Simple DP, published 2023-10-28
- Longest Palindromic Substring - Boolean DP, published 2023-10-27
- Design Add and Search Words Data Structure - Trie structure, published 2023-10-27
- Binary Trees With Factors - DP on sorted array, published 2023-10-26
- K-th Symbol in Grammar - Simple Recursion, published 2023-10-25
- Find Largest Value in Each Tree Row - BFS and DFS solutions, published 2023-10-24
- Constrained Subsequence Sum - Sliding window DP with heap, published 2023-10-21
- Parallel Courses III - Process in topological order, published 2023-10-20
- Parallel Courses II - DFS + DP + Bitmasking, published 2023-10-20
- Validate Binary Tree Nodes - DFS solution, published 2023-10-17
- Maximum Number of Jumps to Reach the Last Index - DP based solution, published 2023-07-10
- Unique Binary Search Trees II - Recursion and memoization DP, published 2023-06-20
- Special Permutations - DP with bitmask, published 2023-06-20
- Valid Number - DFA using hashmap, published 2023-06-15
- Movement of Robots - Collision means nothing, published 2023-06-15
- Unique Paths II - Top down and bottom up DP, published 2023-06-09
- N-Queens - Backtracking intuition, published 2023-06-09
- Multiply Strings - Simple string operations and heuristics, published 2023-06-08
- Extra Characters in a String - Top-down and Bottom-up DP, published 2023-05-29
- Find the Punishment Number of an Integer - Recursion using just integers, published 2023-05-21
- Power of Heroes - One pass solution with detailed explanation, published 2023-05-20
- Evaluate Division - DFS + BFS + DSU solutions, published 2023-05-20
- Combination Sum IV - DFS Recursive Memoization, published 2023-05-20
- Combination Sum - DFS Recursion, published 2023-05-18
- Combination Sum III - DFS Recursion, published 2023-05-18
- Combination Sum II - DFS Recursion, published 2023-05-18
- Maximum Number of Moves in a Grid - DFS + BFS + DP solutions, published 2023-05-17
- Neighboring Bitwise XOR - Simple O(n) solution, published 2023-05-15
- Count the Number of Complete Components - DFS + BFS + DSU solutions, published 2023-05-14
- Count Ways To Build Good Strings - Top-down and bottom-up DP with intuition, published 2023-05-13
- Solving Questions With Brainpower - Top-down and bottom-up DP with intuition, published 2023-05-12
- Permutation Sequence - Recursive + iterative solution with intuition, published 2023-05-11
- Regular Expression Matching - Recursion and memoization, published 2023-05-10
- Number of Provinces - Union Find in C++ and Java, published 2023-04-29
- Checking Existence of Edge Length Limited Paths - Union-Find with sorted edges and queries, published 2023-04-29
- Similar String Groups - DFS + BFS + Union-Find solutions, published 2023-04-28
- Minimize the Total Price of the Trips - DFS + DP solution with explanation, published 2023-04-27
- Bulb Switcher - Easy explanation, published 2023-04-27
- Restore The Array - Step-by-step recursive memoization, published 2023-04-26
- Smallest Number in Infinite Set - Hashset, Min heap based solutions, published 2023-04-25
- Profitable Schemes - Memoization step by step, published 2023-04-24
- Maximum Width of Binary Tree - Step by step BFS, published 2023-04-24
- Reduction Operations to Make the Array Elements Equal - Sort and count using hashmap [Short + Easy], published 2023-04-19
- Minimum Additions to Make Valid String - Multiple solutions explained, published 2023-04-18
- Maximum Value of K Coins From Piles - Bottom-up DP explained, published 2023-04-15
- Cousins in Binary Tree II - DFS solution + BFS solution, published 2023-04-15
- Longest Palindromic Subsequence - Bottom-up DP explained, published 2023-04-14
- Longest Palindromic Subsequence - Bottom-up + Top-down DP explained, published 2023-04-14
- Removing Stars From a String - Simple stack solution, published 2023-04-11
- Design Browser History - Simple array solution [Easy + Short], published 2023-03-18
- Convert Sorted List to Binary Search Tree - An elegant solution, published 2023-03-11
- String Compression - Simple two pointer solution, published 2023-03-02
- Construct Quad Tree - 3 ways to do recursion, flyweight pattern, published 2023-02-27
- Minimum Impossible OR - First missing positive + Bit manipulation [Easy to understand], published 2023-02-22
- Capacity To Ship Packages Within D Days - Binary search with proper explanation, published 2023-02-22
- 4Sum - K Sum solution explained, published 2023-02-22
- Count the Number of Square-Free Subsets - No DFS, No DP, Just Bitmask + simple counting, published 2023-02-21
- Put Marbles in Bags - 2 Heap solution with explaination, published 2023-02-17
- Substring XOR Queries - Clean HashMap solution, published 2023-02-13
- As Far from Land as Possible - Multi Source BFS, published 2023-02-10
- Naming a Company - HashSet for all letters, published 2023-02-09
- Subarrays with K Different Integers - Sliding window + HashMap, published 2023-02-07
- Fruit Into Baskets - Reaching the best solution, published 2023-02-07
- Zigzag Conversion - Easy Method, published 2023-02-03
- Word Break II - Word Break extension (DP), published 2023-01-27
- Concatenated Words - Word Break extension (DP), published 2023-01-27
- Increment Submatrices by One - Cumulative Sum, published 2023-01-15
- Sum of Subarray Minimums - Monotonic Stack + DP, published 2023-01-06
- Day of the Year - Intuitive C++ solution, published 2023-01-05
- Longest Absolute File Path - Monotonic stack solution explained, published 2022-12-29
- Keys and Rooms - DFS + BFS solutions, published 2022-12-20
- Daily Temperatures - Monotonic stack, published 2022-12-20
- Paths in Matrix Whose Sum Is Divisible by K - 3D DP table, published 2022-11-30
- Maximum Profit in Job Scheduling - [Explained + Example] DP (Knapsack)+ OOP Faster than 97%, published 2022-11-26
- Is Graph Bipartite? - BFS, published 2022-11-19
- Rectangle Area - Overlapping intervals expand idea from 1D, published 2022-11-17
- Word Search II - [Explained] Trie + DFS Clean C++ code, published 2022-11-16
- Count Complete Tree Nodes - Recursivle solution with explanation, published 2022-11-16
- Minimum Number of Operations to Sort a Binary Tree by Level - BFS + Min swaps to sort, published 2022-11-13
- Odd String Difference - O(1) space + 100% faster, published 2022-11-12
- Rotting Oranges - Easy BFS, published 2022-10-25
- Reverse Nodes in k-Group - Well explained solution in easy way, published 2022-10-25
- Palindromic Substrings - C++ DP with explanation, published 2022-10-25
- Minimum Path Sum - Easy O(m*n), published 2022-10-25
- Find Minimum in Rotated Sorted Array - Iterative binary search, published 2022-10-25
- Decode String - C++ Stack 100%, published 2022-10-25
- Word Break - Easy Concise DP, published 2022-10-21
- Wiggle Sort II - Trial and Error, published 2022-10-21
- Insert Delete GetRandom O(1) - Simple Hashset, published 2022-10-21
- Factorial Trailing Zeroes - [Easy] One liner, published 2022-10-21
- Contains Duplicate II - Hashset, published 2022-10-21
- Top K Frequent Words - [C++,Python(3/1 lines)] Two methods: Sorting / Max heap, published 2022-10-19
- Search a 2D Matrix II - Top right to bottom left, published 2022-10-18
- Min Stack - Beauty of OOP, published 2022-10-18
- Count Primes - Sieve of Eratosthenes with Exaplanation, published 2022-10-15
- Populating Next Right Pointers in Each Node - BFS+Queue O(1) space, O(n) time, published 2022-10-14
- Delete the Middle Node of a Linked List - One pass tortoise and hare, published 2022-10-14
- Flatten Nested List Iterator - Simple Recursion, published 2022-10-13
- Delete Node in a Linked List - 3 solutions, published 2022-10-13
- Course Schedule II - [Two methods] Kahn's Algorithm and DFS, published 2022-10-12
- Copy List with Random Pointer - C++ Hashmap, published 2022-10-11
- Break a Palindrome - [6 liner] Simple logic simple solution, published 2022-10-10
- Time Based Key-Value Store - HashMap + Ordered Map, published 2022-10-06
- Plus One - Simple c++ solution with explanation, published 2022-10-06
- Binary Tree Zigzag Level Order Traversal - BFS using Queue, published 2022-10-06
- Spiral Matrix - Spiral traversal, published 2022-10-04
- Longest Increasing Subsequence - Two DP solutions, published 2022-10-04
- Group Anagrams - Easy hashmap, published 2022-10-04
- Count and Say - Two pointer solution, published 2022-10-04
- Number of Dice Rolls With Target Sum - Easy DP with examples, published 2022-10-03
- Minimum Time to Make Rope Colorful - Easy approach O(N) solution based on RLE, published 2022-10-03
- Decode Ways - DP Easy Way, published 2022-10-01
- Shortest Common Supersequence - DP LCS variations, published 2022-09-27
- Push Dominoes - Nearest domino on each side, published 2022-09-27
- Count Sub Islands - DFS solution, published 2022-09-27
- Partition List - Easy One pass O(1) space solution, published 2022-07-22
- Longest String Chain - Very Easy Hashmap solution + Analysis, published 2022-06-15
- All Paths From Source to Target - Easy DFS solution, published 2022-06-15
- Delete Operation for Two Strings - Edit Distance + LCS DP solutions, published 2022-06-14
- Next Greater Element II - NGE using stack on repeated array, published 2022-06-04
- Next Greater Element I - Stack + HashMap O(N1+N2) solution, published 2022-06-02
- Populating Next Right Pointers in Each Node II - Connections using Level Wise Traversal DFS, published 2022-05-13
- Binary Tree Level Order Traversal - Three methods - Two DFS + One BFS, published 2022-05-13
- Count Sorted Vowel Strings - DP solution, published 2022-05-12
- 132 Pattern - O(N^3), O(N^2), O(N log N) and O(N) solutions, published 2022-05-10
- Letter Combinations of a Phone Number - Iterative solution, published 2022-05-09
- Remove All Adjacent Duplicates in String II - Solution using stack, published 2022-05-06
- Max Number of K-Sum Pairs - Two Sum Approach, published 2022-05-04
- Smallest String With Swaps - DFS solution, published 2022-04-27
- Encode and Decode TinyURL - Easy HashMap solution, published 2022-04-23
- 3Sum With Multiplicity - 3 Sum over keys, published 2022-04-23
- Design HashSet - Hashing using modulo, published 2022-04-21
- Design HashMap - Hashing using modulo, published 2022-04-21
- Binary Search Tree Iterator - Two solutions: Easy and Medium, published 2022-04-20
- Spiral Matrix II - Two approaches, published 2022-04-19
- Trapping Rain Water - Easy method, published 2022-04-16
- Convert BST to Greater Tree - Easy HashMap solution, published 2022-04-16
- Binary Search Tree to Greater Sum Tree - Easy HashMap solution, published 2022-04-16
- Trim a Binary Search Tree - Recursive C++ solution, published 2022-04-15
- Find Median from Data Stream - Classical solution two heaps, published 2022-03-29
- Number of Steps to Reduce a Number in Binary Representation to One - Simply simulate the steps, published 2022-03-27
- Delete and Earn - House Robber, published 2022-03-05
- Arithmetic Slices - Faster than 100% C++ solutions and also very easy to understand, published 2022-03-03
- Subsets - Simple Iterative solution, published 2022-02-13
- Check If a String Contains All Binary Codes of Size K - HashSet 2 solutions O(n) and O(nk), published 2022-02-13
- Subarray Sum Equals K - O(N) HashMap cummulative sum, published 2022-02-11
- Permutation in String - Sliding window, published 2022-02-11
- Valid Triangle Number - O(N^2) log(N) Binary Search [AC], published 2022-02-09
- House Robber III - Recursion+Memoization [cpp] Explained with intuitions step-wise, published 2022-01-07