Algorithm, data structure and java coding.
Failed to load latest commit information.
BTree/src update lowest common parent of binary tree Jul 29, 2012
DataCenterCooling/src add all src code Jul 7, 2012
FindLargestSubMatrix/src add doc for finding largest area Jul 24, 2012
IntArrayOps/src add a test case forLIS backtrack Jul 25, 2012
LRU/src update doc for basic data structure Jul 24, 2012
MathOps/src update binary tree ops Jul 24, 2012
MinCuttingWords/src add all src code Jul 7, 2012
MirrorMaze/src update mirror maze game doc Jul 29, 2012
PuzzleCoding/src update is bst post order Jul 27, 2012
RePAck/src update doc for basic data structure Jul 25, 2012
StringOps/src update is bst post order Jul 27, 2012
TriangleFunc/src add all src code Jul 7, 2012
allSubsets/src gray code Jul 22, 2012
boggleWords/src add all src code Jul 7, 2012
boldTree/src update doc for basic data structure Jul 25, 2012
coin/src add all src code Jul 7, 2012
find2DArray/src update doc for basic data structure Jul 25, 2012
isNumber/src add all src code Jul 7, 2012
longPalindromicString/src add comments/fix bugs Jul 23, 2012
maxDist/src/nw update doc for basic data structure Jul 25, 2012
permutationStr/src more code Jul 9, 2012
sumZero/src/nw three sum closest Jul 15, 2012


Data Structure, algorithm, dynamic program, recursion and a little bit coding fun!


You are welcome to use code. If you find any bug, please file an issue. I will fix it soon. I will continue publishing new code whenever I see any interesting coding puzzle.

What are included:

Puzzle Coding Fun:

Puzzle Coding It includes a collection of fun coding puzzles.

  • AddBinary: add two binary number from string
  • AddTwoNumber: add two number from arrays
  • BSTtoDLL: convert binary search tree to double linked list
  • BTreeIterator: binary tree iterator: in-order, pre-order, post-order
  • BuildBT: build binary from array inputs
  • ClimbStairs: climb stair problem
  • CombinationPermutation: combination and permutation problems
  • CombinationSum: the sum of combination in array
  • CompareArrayBST: compare binary search tree
  • DecodeNumber: how many ways to decode number
  • FindMiddleShiftedSorted: find the middle elements of shifted sorted array
  • GenerateParentheses: generate parentheses and valid parentheses string
  • GrayCode: gray code
  • HanoiTower: Hanoi tower game
  • InsertCyclicList: insert element into a cyclic list
  • IntervalComparator: merge interval comparator class
  • IntToString: convert integer into A, B, C,.. AA, AB...
  • IsBST: validate binary search tree
  • IsBSTPostOrder: check if an array is a post-order bst.
  • JumpGame: Jump Game
  • LargestBSTSubtree: largest BST which may or may not include all children
  • LongestBalanceSubstring: longest balanced substring
  • LongestPalindrome: a linear way to find a longest palindrome string
  • LongestStringWithoutRepeat: longest string without repeat
  • MaxInWindow: max value in a sliding window
  • MergeIntervals: merge intervals
  • MergeSortedArray: k-way merge sorted arrays, using min heap
  • MinCostSortedArray: cost to sort array
  • MinCuttingWords: the minimal way to cut string based on dictionary
  • MinHeap: min heap implementation
  • MinPathSum: min sum of path (DP and Dijkstra)
  • MinWindowSubString: minimal window of substring
  • Node: tree node
  • Queen: Queen game
  • QueueByStack: implement queue with stack
  • Rand: Random number, rejecting sampling
  • RegexMatch: regex string match
  • ScrambleString: scramble string puzzle
  • SearchInRotatedSortedArray: search in rotated sorted array
  • SecondLargeInt: the second large int in array
  • SetMatrixZero: set matrix to zero (in-place)
  • SimplifyUnixPath: simply unix directory path
  • SpiralMatrix: generate spiral matrix
  • StablePartition: in-place partition array
  • StringAnagram: anagram string
  • ThreeSumClosest: three sum closest to a num in array
  • TreeLeafPath: tree leaf path print
  • Trie: trie implementation
  • ValidSudoku: valid Sudoku game
  • WordEditDistance: calculate the distance of word
  • ZigZagPrintMatrix: zigzag print matrix

Basic data structure and algorithm:

  • ActivityZero
  • allSubsets
  • BlockingQueue
  • boggleWords
  • boldTree
  • BTree
  • coin
  • DataCenterCooling
  • find2DArray
  • FindLargestSubMatrix
  • IntArrayOps
  • isNumber
  • longPalindromicString
  • LRU
  • MathOps
  • maxDist
  • MinCuttingWords
  • permutationStr
  • RePack
  • StringOps
  • sumZero
  • TreeOps
  • TriangleFunc
  • MirrorMaze


There is no license. If you want to use any code in book, please contact with me. Please feel free to refer the code with GitHub.