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 search tree (BST)
- +-*/ expression calculation
- bubble sort
- data structure that supports O(1) add, del, and getRandom
- counting sort
- find the kth smallest
- get binary tree paths
- get most continuous repeated characters
- hashmap
- find primes in range of n
- heap sort
- insertion sort
- median of stream
- merge sort
- most repeated number
- prime factors
- prime within range n
- quicksort iterative
- quicksort recursive
- random shuffle
- reverse string
- reverse words in string
- selection sort
- stack with min
- strcmp
- subarray with sum zero
- 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)
- Search Insert Position (python)
- Binary Tree Inorder (python)
- Linked List Cycle (python)
- Binary Tree Preorder (python)
- Max Depth of Binary Tree (python)
- Unique Binary Search Tree (python)
- Populating Next Right Point in Each Node (python)
- Populating Next Right Point in Each Node II (python)
- Remove Duplicate from List (python)
- Reverse Int (python)
- Same Tree (python)
- Single Number (python)
- Best Time to Buy and Sell Stock 2 (python)