Very little is needed to make a happy life;
it is all within yourself, in your way of thinking.
subscribe via RSS
algorithm
Weighted Quick Union with Path Compression
To solve the dynamic connectivity problem, we need to use an efficient way to find if two nodes are connected, if not, connect them.
algorithm
Implement Trie
A trie or prefix tree is a kind of search tree, that is used to store a dynamic set or associative array where the keys are usually strings. It can be used in word searching, word suggestion and more.
algorithm
Subsets-Problem-on-Backtracking-Method
In backtracking algorithms you try to build a solution one step at a time. If at some step it become clear that the current path that you are on cannot lead to a solution you go back to the previous step (backtrack) and choose a different path.
algorithm
Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
algorithm
K Sum Problem
The base idea is to use hash table in 2sum to make it O(N) complexity. If need to find unique solution, need to use sort() and set() sometimes.