The Coding Interview Bootcamp: Data structure and algorithm.
Part 1
String Reverse
1 | function reverse(str) { |
Paldinromes
1 | function palindrome(str) { |
another way is based on recursive method:
1 | function palindromeRecursive(str) { |
Longest Paldinromes substring
1 | function longestPalin(str) { |
Integer Reversal
1 | // --- Directions |
Anagrams
method1
1 | function anagrams(stringA, stringB) { |
method2
1 | function anagrams(stringA, stringB) { |
Printing Steps
The effect we need is as following:
1 | --- Examples |
solution based on recursive methods
1 | function steps(n, row = 0, stair = '') { |
Enter the Matrix Spiral
The requirement goes as following:
1 | --- Examples |
solution:
1 | function matrix(n) { |
Fibonacci
solution based on memoization and recursive.
1 | function memoize(fn) { |
The most simplified method goes as following:
1 | function memoize(fn) { |
Make it more abstract like below:
1 | function memoize(fn) { |
Queue and Stack
1 | class Queue { |
Linked List
1 | class Node { |
Find the midpoint of linked list
1 | --- Directions |
Multiply two Big numbers
1 | function addbyStr(str1, str2) { |