Include the test-cases and the sketch of the algorithms for the common algorithm questions.
File Organization:
- basic: basic algorithms
- cc150: the problems in cracking the code interview
- dp: the popular dynamic programming problems, excluding the problems in cc150 and lc
- imagong: the problems on http://imagong.com/
- lc: the problems in leetcode
- recursive: the popular recursive problem, excluding the problems in cc150 and lc
#Problem List:
- array calculation
- binary search
- binary tree
- binary tree inorder iterator
- binary tree postorder iterator
- binary search tree (BST)
- +-*/ expression calculation
- bubble sort
- burglarizing house
- Burrows Wheeler Transform
- circular buffer
- data structure that supports O(1) add, del, and getRandom
- counting sort
- deduplicate
- find the kth smallest
- get binary tree paths
- get most continuous repeated characters
- hashmap
- find primes in range of n
- heap sort
- insertion sort
- find largest square submatrix
- find max with random position
- median of stream
- merge sort
- most repeated number
- one edit distance
- prime factors
- prime within range n
- quicksort iterative
- quicksort recursive
- random shuffle
- read4K
- remove zeros from array
- reverse string
- reverse words in string
- selection sort
- stack with min
- strcmp
- subarray sum
- subarray with sum zero
- trie
- union find
- union of two sorted linked list
- all unique character
- reverse string
- whether one string is the permutation of the other
- replace blank space with '%20'
- run-length encoding
- rotate image in place
- set matrix zeros
- check string rotation using substring
- remove duplicate from unsorted linked list
- find the kth to the last from a singly linked list (needs improvement)
- delete the middle element from linked list (needs improvement)
- partition list
- add numbers
- detect the begining of the loop
- check whether a linked list is a palindrome (needs improvement)
- use an array to implement three stacks (not implemented)
- add 'push', 'pop', and 'min' operations for stack, all operations should be in O(1)
- set of stacks
- hanoi
- implement a queue with two stacks
- sort the elements in stack in ascending order
- animal shelter
- validate balanced binary tree
- check whether route exists in a directed graph (needs improvement)
- create minimal height binary tree
- traverse binary tree by level (needs improvement)
- validate binary search tree
- link the next sibling of binary tree
- lowest common ancestor (LCA)
- sub-tree matching
- find all paths in a binary tree that sum to a specific value (needs improvement)
- insert bits M into N
- represent double in binary
- next number with same number of 1
- number of bits different between A and B
- swap odd and even bits in an integer
- find missing number with fetch operation
- Choose game
- probability of collision
- line intersection
- implement -, *, / with + only
- find line that evenly cuts two squares
- line passes the most points
- find the kth number consists of 3, 5, 7
- climbing stairs
- unique paths
- find the magic index
- generate all permutations
- generate parenthesis
- paint fill
- find changes
- eight queens
- tallest stack
- merge two arrays
- anagram
- search in rotated array
- find string in an empty string interspersed array
- find element in sorted matrix
- get the rank of elements in stream
- Swap two numbers in place
- Validate tic-tac-toe
- Counts # of trailing 0's in n!
- Find max without comparison
- Find range to sort
- Max subarray
- Implements rand7 using rand5
- Two sum
- Convert BST to Doubly Linked List
- Add two numbers withoug +
- Random suffling
- m out of n reservoir sampling
- Count # 2's in range 0 to n
- Find smallest 1 million in 1 billion
- Find the longest word made of other words in dictionary
- [Batched substring match] (https://github.com/yxjiang/algorithms/blob/master/src/main/java/algorithm/cc150/chapter18/Question8.java)
- Find the median of a sequence of data
- [Word Ladder] (https://github.com/yxjiang/algorithms/blob/master/src/main/java/algorithm/cc150/chapter18/Question10.java)
- [Maximal submatrix with black pixel borders] (https://github.com/yxjiang/algorithms/blob/master/src/main/java/algorithm/cc150/chapter18/Question11.java)
- Maximal submatrix
- find # distinct ways to reach score
- longest common substring (LCA)
- longest increasing subsequences (LIS)
- Add Binary (java)
- Add Two Numbers (java)
- Anagram (python)
- Balanced Binary Tree (python) (java)
- Search Insert Position (python)
- Climb Stairs (python)
- Container with Most Water (java) (python)
- Convert Sorted Array to BST (python) (java)
- Convert Sorted List to BST (python) (java)
- Binary Tree Inorder (python)
- Int to Roman (python)
- Linked List Cycle (python)
- Binary Tree Preorder (python)
- Generate Parentheses (python) (java)
- Max Depth of Binary Tree (python)
- Maximum Subarray (python) (java)
- Merge Two Sorted Lists (python) (java)
- N-Queens (python) (java)
- N-Queens II (python) (java)
- Unique Binary Search Tree (python)
- Pascal Triangle (python) (java)
- Pascal Triangle II (python) (java)
- Plus One (python) (java)
- Populating Next Right Point in Each Node (python)
- Populating Next Right Point in Each Node II (python)
- Regular Expression Matching (java) (python)
- Remove Duplicates from Sorted List (python) (java)
- Remove Duplicates from Sorted List II (python) (java)
- Remove Duplicates from Sorted Array (python) (java)
- Remove Duplicates from Sorted Array II (python) (java)
- Remove Element (python) (java)
- Reverse Int (python)
- Roman to Int (python)
- Same Tree (python)
- Single Number (python)
- Best Time to Buy and Sell Stock 2 (python)
- Single Number II (java (python)
- Sort Color (python)
- Swap Nodes in Pairs (python) (java)
- Symmetric Tree (python) (java)