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.
[Puzzle Coding] (https://github.com/xiaoningning/algorithm/tree/master/PuzzleCoding) 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
- 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.