My Take on the KMP Algorithm
The Knuth-Morris-Pratt (KMP) algorithm is an advanced string matching algorithm that efficiently finds all occurrences of a pattern string pat within a text string text. It avoids redundant compa...
The Knuth-Morris-Pratt (KMP) algorithm is an advanced string matching algorithm that efficiently finds all occurrences of a pattern string pat within a text string text. It avoids redundant compa...
[Problem] Tree Depth-First Search Breadth-First Search Graph Tip: Solve Leetcode 1245. Tree Diameter (Unlocked) before attempting this question to gain a foundational understanding. In...
[Problem] Array Breadth-First Search Graph Heap (Priority Queue) Matrix Shortest Path Intuition We need to find the minimum cost to travel from the top-left to the bottom-right corner of ...
[Problem] Array Bit Manipulation Intuition Remember the properties of XOR: a ^ a = 0 a ^ 0 = a a ^ b = b ^ a [Commutativity] (a ^ b) ^ c = a ^ (b ^ c) [Associativity] ...
[Problem] Array Bit Manipulation Intuition The task is to find XOR of all possible pairings from nums1 and nums2 Remember the properties of XOR: a ^ a = 0 a ^ 0 = a a ...
[Problem] Greedy Bit Manipulation Intuition The task is to minimize the XOR value between two numbers, x and num1, while ensuring that x has the same number of set bits (1’s) as num2. ...
[Problem] Hash Table Array Bit Manipulation Intuition Given two 0-indexed integer permutations A and B of length n, we aim to find a prefix common array C. The problem es...
[Problem] Hash Table String Counting Intuition Key Observations: Frequency of characters determines the final outcome, no matter the order! If a character appears less ...
[Problem] String Stack Greedy Intuition s: Firstly, a valid string will always have pairs of ( and ), meaning the length of the string must be even. s: Secondly, each ( w...
[Problem] Hash Table String Greedy Counting Intuition A palindrome reads the same forward and backward. Even Length Palindrome : If a string has an even length, all chara...