Union Find From wiki: In computer science, a disjoint-set data structure, also called a union–find data structure or merge–find set, is a data structure that keeps track of a set of elements...
Single Number XOR features: a ^ b = c a ^ c = b b ^ c = a a ^ 0 = a a ^ a = 0 (a ^ b) ^ c = a ^ (b ^ c) - I: all the numbers appear twice except one XOR all the numbers, and the result is the one -...
Data Structure is a way to organize data. It provides some methods to handle data stream, e.g. insert, delete, etc. Linear Data Structure Queue & Stack Min Stack Use two stacks, one is storing the...
1. Dynamic Programming A method for solving a complex problem by breaking it down into a collection of simpler sub-problems. 1.1 When to use 1. One of the following three: - Maximum/Minimum Problem -...
1. Introduce Dummy Node When the head of the target list we want to return may be different from the original given list, we can use a dummy node linked to the result so that we can get what we want...
1. Binary Tree DFS Traversal 1.1 Recursion This method will cost O(n) time with no extra space. The space is assigned by system(which could be O(1) or O(h), h is the height of the tree). ` java...
Binary Search For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number does not exist in the array, return...
Coding Style 1. Leave blank space around each operations 2. Give meaningful names to parameters 3. Add space line between two logic blocks For example, Implement strStr(): ` java public class...