diff --git a/chapter01/1.1 - Is Unique/isUnique.js b/chapter01Arrays/1.1 - Is Unique/isUnique.js similarity index 100% rename from chapter01/1.1 - Is Unique/isUnique.js rename to chapter01Arrays/1.1 - Is Unique/isUnique.js diff --git a/chapter01/1.2 - Check Perm/checkPermute.js b/chapter01Arrays/1.2 - Check Perm/checkPermute.js similarity index 100% rename from chapter01/1.2 - Check Perm/checkPermute.js rename to chapter01Arrays/1.2 - Check Perm/checkPermute.js diff --git a/chapter01/1.3 - URLify/urlify-2.js b/chapter01Arrays/1.3 - URLify/urlify-2.js similarity index 100% rename from chapter01/1.3 - URLify/urlify-2.js rename to chapter01Arrays/1.3 - URLify/urlify-2.js diff --git a/chapter01/1.3 - URLify/urlify.js b/chapter01Arrays/1.3 - URLify/urlify.js similarity index 100% rename from chapter01/1.3 - URLify/urlify.js rename to chapter01Arrays/1.3 - URLify/urlify.js diff --git a/chapter01/1.4 - PalinPerm/palinPerm.js b/chapter01Arrays/1.4 - PalinPerm/palinPerm.js similarity index 100% rename from chapter01/1.4 - PalinPerm/palinPerm.js rename to chapter01Arrays/1.4 - PalinPerm/palinPerm.js diff --git a/chapter01/1.5 - OneAway/oneAway.js b/chapter01Arrays/1.5 - OneAway/oneAway.js similarity index 100% rename from chapter01/1.5 - OneAway/oneAway.js rename to chapter01Arrays/1.5 - OneAway/oneAway.js diff --git a/chapter01/1.6 - String Compression/strComp.js b/chapter01Arrays/1.6 - String Compression/strComp.js similarity index 100% rename from chapter01/1.6 - String Compression/strComp.js rename to chapter01Arrays/1.6 - String Compression/strComp.js diff --git a/chapter01/1.7 - Rotate Matrix/rotateMatrix.js b/chapter01Arrays/1.7 - Rotate Matrix/rotateMatrix.js similarity index 100% rename from chapter01/1.7 - Rotate Matrix/rotateMatrix.js rename to chapter01Arrays/1.7 - Rotate Matrix/rotateMatrix.js diff --git a/chapter01/1.8 - Zero Matrix/zeroMatrix.js b/chapter01Arrays/1.8 - Zero Matrix/zeroMatrix.js similarity index 100% rename from chapter01/1.8 - Zero Matrix/zeroMatrix.js rename to chapter01Arrays/1.8 - Zero Matrix/zeroMatrix.js diff --git a/chapter01/1.9 - String Rotation/stringRotation.js b/chapter01Arrays/1.9 - String Rotation/stringRotation.js similarity index 100% rename from chapter01/1.9 - String Rotation/stringRotation.js rename to chapter01Arrays/1.9 - String Rotation/stringRotation.js diff --git a/chapter02/2.1 - Remove Dups/removeDups.js b/chapter02LinkedLists/2.1 - Remove Dups/removeDups.js similarity index 100% rename from chapter02/2.1 - Remove Dups/removeDups.js rename to chapter02LinkedLists/2.1 - Remove Dups/removeDups.js diff --git a/chapter02/2.2 - Return Kth to Last/returnKthToLast.js b/chapter02LinkedLists/2.2 - Return Kth to Last/returnKthToLast.js similarity index 100% rename from chapter02/2.2 - Return Kth to Last/returnKthToLast.js rename to chapter02LinkedLists/2.2 - Return Kth to Last/returnKthToLast.js diff --git a/chapter02/2.3 - Delete Middle Node/deleteMiddleNode.js b/chapter02LinkedLists/2.3 - Delete Middle Node/deleteMiddleNode.js similarity index 100% rename from chapter02/2.3 - Delete Middle Node/deleteMiddleNode.js rename to chapter02LinkedLists/2.3 - Delete Middle Node/deleteMiddleNode.js diff --git a/chapter02/2.4 - Partition/partition.js b/chapter02LinkedLists/2.4 - Partition/partition.js similarity index 100% rename from chapter02/2.4 - Partition/partition.js rename to chapter02LinkedLists/2.4 - Partition/partition.js diff --git a/chapter02/2.5 - Sum Lists/sumLists - forward.js b/chapter02LinkedLists/2.5 - Sum Lists/sumLists - forward.js similarity index 100% rename from chapter02/2.5 - Sum Lists/sumLists - forward.js rename to chapter02LinkedLists/2.5 - Sum Lists/sumLists - forward.js diff --git a/chapter02/2.5 - Sum Lists/sumLists - recursion.js b/chapter02LinkedLists/2.5 - Sum Lists/sumLists - recursion.js similarity index 100% rename from chapter02/2.5 - Sum Lists/sumLists - recursion.js rename to chapter02LinkedLists/2.5 - Sum Lists/sumLists - recursion.js diff --git a/chapter02/2.5 - Sum Lists/sumLists.js b/chapter02LinkedLists/2.5 - Sum Lists/sumLists.js similarity index 100% rename from chapter02/2.5 - Sum Lists/sumLists.js rename to chapter02LinkedLists/2.5 - Sum Lists/sumLists.js diff --git a/chapter02/2.6 - Palindrome/palindrome.js b/chapter02LinkedLists/2.6 - Palindrome/palindrome.js similarity index 100% rename from chapter02/2.6 - Palindrome/palindrome.js rename to chapter02LinkedLists/2.6 - Palindrome/palindrome.js diff --git a/chapter02/2.7 - Intersection/intersection.js b/chapter02LinkedLists/2.7 - Intersection/intersection.js similarity index 100% rename from chapter02/2.7 - Intersection/intersection.js rename to chapter02LinkedLists/2.7 - Intersection/intersection.js diff --git a/chapter02/2.8 - Loop Detection/loopDetection.js b/chapter02LinkedLists/2.8 - Loop Detection/loopDetection.js similarity index 100% rename from chapter02/2.8 - Loop Detection/loopDetection.js rename to chapter02LinkedLists/2.8 - Loop Detection/loopDetection.js diff --git a/chapter02/util/LinkedList.js b/chapter02LinkedLists/util/LinkedList.js similarity index 100% rename from chapter02/util/LinkedList.js rename to chapter02LinkedLists/util/LinkedList.js diff --git a/chapter02/util/printList.js b/chapter02LinkedLists/util/printList.js similarity index 100% rename from chapter02/util/printList.js rename to chapter02LinkedLists/util/printList.js diff --git a/chapter03/3.1 - Three in One/threeInOne.js b/chapter03StackQueues/3.1 - Three in One/threeInOne.js similarity index 100% rename from chapter03/3.1 - Three in One/threeInOne.js rename to chapter03StackQueues/3.1 - Three in One/threeInOne.js diff --git a/chapter03/3.2 - Stack Min/stackMin.js b/chapter03StackQueues/3.2 - Stack Min/stackMin.js similarity index 100% rename from chapter03/3.2 - Stack Min/stackMin.js rename to chapter03StackQueues/3.2 - Stack Min/stackMin.js diff --git a/chapter03/3.3 - Stack of Plates/stackOfPlates.js b/chapter03StackQueues/3.3 - Stack of Plates/stackOfPlates.js similarity index 100% rename from chapter03/3.3 - Stack of Plates/stackOfPlates.js rename to chapter03StackQueues/3.3 - Stack of Plates/stackOfPlates.js diff --git a/chapter03/3.4 - Queue via Stacks/queueViaStacks.js b/chapter03StackQueues/3.4 - Queue via Stacks/queueViaStacks.js similarity index 100% rename from chapter03/3.4 - Queue via Stacks/queueViaStacks.js rename to chapter03StackQueues/3.4 - Queue via Stacks/queueViaStacks.js diff --git a/chapter03/3.5 - Sort Stack/sortStack.js b/chapter03StackQueues/3.5 - Sort Stack/sortStack.js similarity index 100% rename from chapter03/3.5 - Sort Stack/sortStack.js rename to chapter03StackQueues/3.5 - Sort Stack/sortStack.js diff --git a/chapter03/3.6 - Animal Shelter/animalShelter.js b/chapter03StackQueues/3.6 - Animal Shelter/animalShelter.js similarity index 97% rename from chapter03/3.6 - Animal Shelter/animalShelter.js rename to chapter03StackQueues/3.6 - Animal Shelter/animalShelter.js index 342f14d..73471d1 100644 --- a/chapter03/3.6 - Animal Shelter/animalShelter.js +++ b/chapter03StackQueues/3.6 - Animal Shelter/animalShelter.js @@ -12,7 +12,7 @@ var AnimalShelter = function() { AnimalShelter.prototype.enqueue = function(animal) { if (animal.type === 'dog') { this.dogQ.enqueue(animal); - } else if (animal.type === 'vat') { + } else if (animal.type === 'cat') { this.catQ.enqueue(animal); } this.allQ.enqueue(animal); diff --git a/chapter03/util/LinkedList.js b/chapter03StackQueues/util/LinkedList.js similarity index 100% rename from chapter03/util/LinkedList.js rename to chapter03StackQueues/util/LinkedList.js diff --git a/chapter03/util/Queue.js b/chapter03StackQueues/util/Queue.js similarity index 100% rename from chapter03/util/Queue.js rename to chapter03StackQueues/util/Queue.js diff --git a/chapter03/util/Stack.js b/chapter03StackQueues/util/Stack.js similarity index 100% rename from chapter03/util/Stack.js rename to chapter03StackQueues/util/Stack.js diff --git a/chapter04/4.01 - Route Between Nodes/routeBetweenNodes.js b/chapter04TreesGraphs/4.01 - Route Between Nodes/routeBetweenNodes.js similarity index 100% rename from chapter04/4.01 - Route Between Nodes/routeBetweenNodes.js rename to chapter04TreesGraphs/4.01 - Route Between Nodes/routeBetweenNodes.js diff --git a/chapter04/4.02 - Minimal Tree/minimalTree.js b/chapter04TreesGraphs/4.02 - Minimal Tree/minimalTree.js similarity index 100% rename from chapter04/4.02 - Minimal Tree/minimalTree.js rename to chapter04TreesGraphs/4.02 - Minimal Tree/minimalTree.js diff --git a/chapter04/4.03 - List of Depths/listOfDepths.js b/chapter04TreesGraphs/4.03 - List of Depths/listOfDepths.js similarity index 100% rename from chapter04/4.03 - List of Depths/listOfDepths.js rename to chapter04TreesGraphs/4.03 - List of Depths/listOfDepths.js diff --git a/chapter04/4.04 - Check Balanced/checkBalanced.js b/chapter04TreesGraphs/4.04 - Check Balanced/checkBalanced.js similarity index 100% rename from chapter04/4.04 - Check Balanced/checkBalanced.js rename to chapter04TreesGraphs/4.04 - Check Balanced/checkBalanced.js diff --git a/chapter04/4.05 - Validate BST/validateBST.js b/chapter04TreesGraphs/4.05 - Validate BST/validateBST.js similarity index 100% rename from chapter04/4.05 - Validate BST/validateBST.js rename to chapter04TreesGraphs/4.05 - Validate BST/validateBST.js diff --git a/chapter04/4.06 - Successor/successor.js b/chapter04TreesGraphs/4.06 - Successor/successor.js similarity index 100% rename from chapter04/4.06 - Successor/successor.js rename to chapter04TreesGraphs/4.06 - Successor/successor.js diff --git a/chapter04/4.07 - Build Order/buildOrder.js b/chapter04TreesGraphs/4.07 - Build Order/buildOrder.js similarity index 100% rename from chapter04/4.07 - Build Order/buildOrder.js rename to chapter04TreesGraphs/4.07 - Build Order/buildOrder.js diff --git a/chapter04/4.08 - First Common Ancestor/firstCommonAncestor.js b/chapter04TreesGraphs/4.08 - First Common Ancestor/firstCommonAncestor.js similarity index 100% rename from chapter04/4.08 - First Common Ancestor/firstCommonAncestor.js rename to chapter04TreesGraphs/4.08 - First Common Ancestor/firstCommonAncestor.js diff --git a/chapter04/4.09 - BST Sequences/bstSequences.js b/chapter04TreesGraphs/4.09 - BST Sequences/bstSequences.js similarity index 100% rename from chapter04/4.09 - BST Sequences/bstSequences.js rename to chapter04TreesGraphs/4.09 - BST Sequences/bstSequences.js diff --git a/chapter04/4.10 - Check Subtree/checkSubtree.js b/chapter04TreesGraphs/4.10 - Check Subtree/checkSubtree.js similarity index 100% rename from chapter04/4.10 - Check Subtree/checkSubtree.js rename to chapter04TreesGraphs/4.10 - Check Subtree/checkSubtree.js diff --git a/chapter04/4.11 - Random Node/randomNode.js b/chapter04TreesGraphs/4.11 - Random Node/randomNode.js similarity index 100% rename from chapter04/4.11 - Random Node/randomNode.js rename to chapter04TreesGraphs/4.11 - Random Node/randomNode.js diff --git a/chapter04/4.12 - Paths with Sum/pathsWithSum.js b/chapter04TreesGraphs/4.12 - Paths with Sum/pathsWithSum.js similarity index 100% rename from chapter04/4.12 - Paths with Sum/pathsWithSum.js rename to chapter04TreesGraphs/4.12 - Paths with Sum/pathsWithSum.js diff --git a/chapter04/util/BST.js b/chapter04TreesGraphs/util/BST.js similarity index 100% rename from chapter04/util/BST.js rename to chapter04TreesGraphs/util/BST.js diff --git a/chapter04/util/Graph.js b/chapter04TreesGraphs/util/Graph.js similarity index 100% rename from chapter04/util/Graph.js rename to chapter04TreesGraphs/util/Graph.js diff --git a/chapter04/util/LinkedList.js b/chapter04TreesGraphs/util/LinkedList.js similarity index 100% rename from chapter04/util/LinkedList.js rename to chapter04TreesGraphs/util/LinkedList.js diff --git a/chapter04/util/Queue.js b/chapter04TreesGraphs/util/Queue.js similarity index 100% rename from chapter04/util/Queue.js rename to chapter04TreesGraphs/util/Queue.js diff --git a/chapter04/util/Stack.js b/chapter04TreesGraphs/util/Stack.js similarity index 100% rename from chapter04/util/Stack.js rename to chapter04TreesGraphs/util/Stack.js diff --git a/chapter04/util/Tree.js b/chapter04TreesGraphs/util/Tree.js similarity index 100% rename from chapter04/util/Tree.js rename to chapter04TreesGraphs/util/Tree.js diff --git a/chapter05/5.1 - Insertion/insertion.js b/chapter05BitManipulation/5.1 - Insertion/insertion.js similarity index 100% rename from chapter05/5.1 - Insertion/insertion.js rename to chapter05BitManipulation/5.1 - Insertion/insertion.js diff --git a/chapter05/5.2 - Binary to String/binaryToString.js b/chapter05BitManipulation/5.2 - Binary to String/binaryToString.js similarity index 100% rename from chapter05/5.2 - Binary to String/binaryToString.js rename to chapter05BitManipulation/5.2 - Binary to String/binaryToString.js diff --git a/chapter05/5.3 - Flip Bit To Win/flipBitToWin.js b/chapter05BitManipulation/5.3 - Flip Bit To Win/flipBitToWin.js similarity index 100% rename from chapter05/5.3 - Flip Bit To Win/flipBitToWin.js rename to chapter05BitManipulation/5.3 - Flip Bit To Win/flipBitToWin.js diff --git a/chapter05/5.4 - Next Number/nextNumber.js b/chapter05BitManipulation/5.4 - Next Number/nextNumber.js similarity index 100% rename from chapter05/5.4 - Next Number/nextNumber.js rename to chapter05BitManipulation/5.4 - Next Number/nextNumber.js diff --git a/chapter05/5.5 - Debugger/debugger.js b/chapter05BitManipulation/5.5 - Debugger/debugger.js similarity index 100% rename from chapter05/5.5 - Debugger/debugger.js rename to chapter05BitManipulation/5.5 - Debugger/debugger.js diff --git a/chapter05/5.6 - Conversion/conversion.js b/chapter05BitManipulation/5.6 - Conversion/conversion.js similarity index 100% rename from chapter05/5.6 - Conversion/conversion.js rename to chapter05BitManipulation/5.6 - Conversion/conversion.js diff --git a/chapter05/5.7 - Pairwise Swap/pairwiseSwap.js b/chapter05BitManipulation/5.7 - Pairwise Swap/pairwiseSwap.js similarity index 100% rename from chapter05/5.7 - Pairwise Swap/pairwiseSwap.js rename to chapter05BitManipulation/5.7 - Pairwise Swap/pairwiseSwap.js diff --git a/chapter05/5.8 - Draw Line/drawLine.js b/chapter05BitManipulation/5.8 - Draw Line/drawLine.js similarity index 100% rename from chapter05/5.8 - Draw Line/drawLine.js rename to chapter05BitManipulation/5.8 - Draw Line/drawLine.js diff --git a/chapter06/6.01 - Heavy Pill/heavyPill.js b/chapter06MathLogic/6.01 - Heavy Pill/heavyPill.js similarity index 100% rename from chapter06/6.01 - Heavy Pill/heavyPill.js rename to chapter06MathLogic/6.01 - Heavy Pill/heavyPill.js diff --git a/chapter06/6.02 - Basketball/basketBall.js b/chapter06MathLogic/6.02 - Basketball/basketBall.js similarity index 100% rename from chapter06/6.02 - Basketball/basketBall.js rename to chapter06MathLogic/6.02 - Basketball/basketBall.js diff --git a/chapter06/6.03 - Dominos/dominos.js b/chapter06MathLogic/6.03 - Dominos/dominos.js similarity index 100% rename from chapter06/6.03 - Dominos/dominos.js rename to chapter06MathLogic/6.03 - Dominos/dominos.js diff --git a/chapter06/6.04 - Ants on a Triangle/antsOnATriangle.js b/chapter06MathLogic/6.04 - Ants on a Triangle/antsOnATriangle.js similarity index 100% rename from chapter06/6.04 - Ants on a Triangle/antsOnATriangle.js rename to chapter06MathLogic/6.04 - Ants on a Triangle/antsOnATriangle.js diff --git a/chapter06/6.05 - Jugs of Water/jugsOfWater.js b/chapter06MathLogic/6.05 - Jugs of Water/jugsOfWater.js similarity index 100% rename from chapter06/6.05 - Jugs of Water/jugsOfWater.js rename to chapter06MathLogic/6.05 - Jugs of Water/jugsOfWater.js diff --git a/chapter06/6.06 - Blue-Eyed Island/blueEyedIsland.js b/chapter06MathLogic/6.06 - Blue-Eyed Island/blueEyedIsland.js similarity index 100% rename from chapter06/6.06 - Blue-Eyed Island/blueEyedIsland.js rename to chapter06MathLogic/6.06 - Blue-Eyed Island/blueEyedIsland.js diff --git a/chapter06/6.07 - The Apocalypse/theApocalypse.js b/chapter06MathLogic/6.07 - The Apocalypse/theApocalypse.js similarity index 100% rename from chapter06/6.07 - The Apocalypse/theApocalypse.js rename to chapter06MathLogic/6.07 - The Apocalypse/theApocalypse.js diff --git a/chapter06/6.08 - The Egg Drop Problem/eggDrop.js b/chapter06MathLogic/6.08 - The Egg Drop Problem/eggDrop.js similarity index 100% rename from chapter06/6.08 - The Egg Drop Problem/eggDrop.js rename to chapter06MathLogic/6.08 - The Egg Drop Problem/eggDrop.js diff --git a/chapter06/6.09 - 100 Lockers/hundredLockers.js b/chapter06MathLogic/6.09 - 100 Lockers/hundredLockers.js similarity index 100% rename from chapter06/6.09 - 100 Lockers/hundredLockers.js rename to chapter06MathLogic/6.09 - 100 Lockers/hundredLockers.js diff --git a/chapter06/6.10 - Poison/poison.js b/chapter06MathLogic/6.10 - Poison/poison.js similarity index 100% rename from chapter06/6.10 - Poison/poison.js rename to chapter06MathLogic/6.10 - Poison/poison.js diff --git a/chapter06/util/notes.js b/chapter06MathLogic/util/notes.js similarity index 100% rename from chapter06/util/notes.js rename to chapter06MathLogic/util/notes.js diff --git a/chapter07/7.01 - Deck of Cards/deckOfCards.js b/chapter07OOD/7.01 - Deck of Cards/deckOfCards.js similarity index 100% rename from chapter07/7.01 - Deck of Cards/deckOfCards.js rename to chapter07OOD/7.01 - Deck of Cards/deckOfCards.js diff --git a/chapter07/7.02 - Call Center/callCenter.js b/chapter07OOD/7.02 - Call Center/callCenter.js similarity index 100% rename from chapter07/7.02 - Call Center/callCenter.js rename to chapter07OOD/7.02 - Call Center/callCenter.js diff --git a/chapter07/7.03 - Jukebox/jukebox.js b/chapter07OOD/7.03 - Jukebox/jukebox.js similarity index 100% rename from chapter07/7.03 - Jukebox/jukebox.js rename to chapter07OOD/7.03 - Jukebox/jukebox.js diff --git a/chapter07/7.04 - Parking Lot/parkingLot.js b/chapter07OOD/7.04 - Parking Lot/parkingLot.js similarity index 100% rename from chapter07/7.04 - Parking Lot/parkingLot.js rename to chapter07OOD/7.04 - Parking Lot/parkingLot.js diff --git a/chapter07/7.05 - Online Book Reader/onlineBookReader.js b/chapter07OOD/7.05 - Online Book Reader/onlineBookReader.js similarity index 100% rename from chapter07/7.05 - Online Book Reader/onlineBookReader.js rename to chapter07OOD/7.05 - Online Book Reader/onlineBookReader.js diff --git a/chapter07/7.06 - Jigsaw/jigsaw.js b/chapter07OOD/7.06 - Jigsaw/jigsaw.js similarity index 100% rename from chapter07/7.06 - Jigsaw/jigsaw.js rename to chapter07OOD/7.06 - Jigsaw/jigsaw.js diff --git a/chapter07/7.07 - Chat Server/chatServer.js b/chapter07OOD/7.07 - Chat Server/chatServer.js similarity index 100% rename from chapter07/7.07 - Chat Server/chatServer.js rename to chapter07OOD/7.07 - Chat Server/chatServer.js diff --git a/chapter07/7.08 - Othello/othello.js b/chapter07OOD/7.08 - Othello/othello.js similarity index 100% rename from chapter07/7.08 - Othello/othello.js rename to chapter07OOD/7.08 - Othello/othello.js diff --git a/chapter07/7.09 - Circular Array/circularArray.js b/chapter07OOD/7.09 - Circular Array/circularArray.js similarity index 100% rename from chapter07/7.09 - Circular Array/circularArray.js rename to chapter07OOD/7.09 - Circular Array/circularArray.js diff --git a/chapter07/7.10 - Minesweeper/minesweeper.js b/chapter07OOD/7.10 - Minesweeper/minesweeper.js similarity index 100% rename from chapter07/7.10 - Minesweeper/minesweeper.js rename to chapter07OOD/7.10 - Minesweeper/minesweeper.js diff --git a/chapter07/7.11 - File System/fileSystem.js b/chapter07OOD/7.11 - File System/fileSystem.js similarity index 100% rename from chapter07/7.11 - File System/fileSystem.js rename to chapter07OOD/7.11 - File System/fileSystem.js diff --git a/chapter07/7.12 - Hash Table/hashTable.js b/chapter07OOD/7.12 - Hash Table/hashTable.js similarity index 100% rename from chapter07/7.12 - Hash Table/hashTable.js rename to chapter07OOD/7.12 - Hash Table/hashTable.js diff --git a/chapter07/util/BST.js b/chapter07OOD/util/BST.js similarity index 100% rename from chapter07/util/BST.js rename to chapter07OOD/util/BST.js diff --git a/chapter07/util/Graph.js b/chapter07OOD/util/Graph.js similarity index 100% rename from chapter07/util/Graph.js rename to chapter07OOD/util/Graph.js diff --git a/chapter07/util/LinkedList.js b/chapter07OOD/util/LinkedList.js similarity index 100% rename from chapter07/util/LinkedList.js rename to chapter07OOD/util/LinkedList.js diff --git a/chapter07/util/Queue.js b/chapter07OOD/util/Queue.js similarity index 100% rename from chapter07/util/Queue.js rename to chapter07OOD/util/Queue.js diff --git a/chapter07/util/Stack.js b/chapter07OOD/util/Stack.js similarity index 100% rename from chapter07/util/Stack.js rename to chapter07OOD/util/Stack.js diff --git a/chapter07/util/Tree.js b/chapter07OOD/util/Tree.js similarity index 100% rename from chapter07/util/Tree.js rename to chapter07OOD/util/Tree.js diff --git a/chapter07/util/notes.js b/chapter07OOD/util/notes.js similarity index 100% rename from chapter07/util/notes.js rename to chapter07OOD/util/notes.js diff --git a/chapter08/8.01 - Triple Step/tripleStep.js b/chapter08/8.01 - Triple Step/tripleStep.js deleted file mode 100644 index 12d1fa4..0000000 --- a/chapter08/8.01 - Triple Step/tripleStep.js +++ /dev/null @@ -1,20 +0,0 @@ -var numWays = function(N) { - var answer = 0; - var recurse = function(number) { - if (number === 0) { - answer++; - } else if (number > 0) { - recurse(number - 1); - recurse(number - 2); - recurse(number - 3); - } - }; - recurse(N); - return answer; -}; - -/* TEST */ - -console.log(numWays(1), 1); -console.log(numWays(2), 2); -console.log(numWays(3), 4); diff --git a/chapter08RecursionDynamic/8.01 - Triple Step/tripleStep.js b/chapter08RecursionDynamic/8.01 - Triple Step/tripleStep.js new file mode 100644 index 0000000..45a64fe --- /dev/null +++ b/chapter08RecursionDynamic/8.01 - Triple Step/tripleStep.js @@ -0,0 +1,81 @@ +/* +Recursion and Dynamic Programming (4 steps) +1. Start with the recursive backtracking solution +2. Optimize by using a memoization table (top-down dynamic programming) +3. Remove the need for recursion (bottom-up dynamic programming) +4. Apply final tricks to reduce the time / memory complexity +*/ + +/* +Triple Step: +A child is running up a staircase with n steps and +can hop either 1 step, 2 steps, or 3 steps at a time. + +Implement a method to count how many possible ways +the child can run up the stairs. + */ + + +var numWays = function(N) { + var answer = 0; + var recurse = function(number) { + if (number === 0) { + answer++; + } else if (number > 0) { + recurse(number - 1); + recurse(number - 2); + recurse(number - 3); + } + }; + recurse(N); + return answer; +}; + +// Recursive BackTracking +// Time & Space O(n!) +/* +var numWays = function(n, res=0) { + if (n < 0) return 0 + if (n === 0) { + res++ + return res + } + return numWays(n - 1) + numWays(n - 2) + numWays(n - 3) +} +*/ + +// Top Down Memoization +// Time & Space O(n) +/* +var numWays = function(n, i=3, memo = [1, 1, 2, 4]) { + if (n < 0) return memo[0] + if (n === 1) return memo[n] + if (i > n ) return memo[memo.length - 1] + memo[i] = memo[i - 1] + memo[i - 2] + memo[i - 3] + return numWays(n, i+1, memo) +} +*/ + +// Bottom Up memoization +// Time & Space O(n) +/* +var numWays = function(n, memo=[1,1,2,4]) { + + for (let i = 3; i <= n; i++) { + memo[i] = memo[i - 1] + memo[i - 2] + memo[i - 3] + } + + return memo[memo.length - 1] +} +*/ + + +/* TEST */ + +console.log(numWays(1), 1); +console.log(numWays(2), 2); +console.log(numWays(3), 4); +console.log(numWays(5), 13) +console.log(numWays(7), 44) +console.log(numWays(10), 274); + diff --git a/chapter08/8.02 - Robot in a Grid/robotInGrid.js b/chapter08RecursionDynamic/8.02 - Robot in a Grid/robotInGrid.js similarity index 100% rename from chapter08/8.02 - Robot in a Grid/robotInGrid.js rename to chapter08RecursionDynamic/8.02 - Robot in a Grid/robotInGrid.js diff --git a/chapter08/8.03 - Magic Index/magicIndex.js b/chapter08RecursionDynamic/8.03 - Magic Index/magicIndex.js similarity index 100% rename from chapter08/8.03 - Magic Index/magicIndex.js rename to chapter08RecursionDynamic/8.03 - Magic Index/magicIndex.js diff --git a/chapter08/8.04 - Power Set/powerSet.js b/chapter08RecursionDynamic/8.04 - Power Set/powerSet.js similarity index 100% rename from chapter08/8.04 - Power Set/powerSet.js rename to chapter08RecursionDynamic/8.04 - Power Set/powerSet.js diff --git a/chapter08/8.05 - Recursive Multiply/recursiveMultiply.js b/chapter08RecursionDynamic/8.05 - Recursive Multiply/recursiveMultiply.js similarity index 100% rename from chapter08/8.05 - Recursive Multiply/recursiveMultiply.js rename to chapter08RecursionDynamic/8.05 - Recursive Multiply/recursiveMultiply.js diff --git a/chapter08/8.06 - Towers of Hanoi/towersHanoi.js b/chapter08RecursionDynamic/8.06 - Towers of Hanoi/towersHanoi.js similarity index 100% rename from chapter08/8.06 - Towers of Hanoi/towersHanoi.js rename to chapter08RecursionDynamic/8.06 - Towers of Hanoi/towersHanoi.js diff --git a/chapter08/8.07 - Permutations without Dups/permWithoutDups.js b/chapter08RecursionDynamic/8.07 - Permutations without Dups/permWithoutDups.js similarity index 100% rename from chapter08/8.07 - Permutations without Dups/permWithoutDups.js rename to chapter08RecursionDynamic/8.07 - Permutations without Dups/permWithoutDups.js diff --git a/chapter08/8.08 - Permutations with Dups/permWithDups.js b/chapter08RecursionDynamic/8.08 - Permutations with Dups/permWithDups.js similarity index 100% rename from chapter08/8.08 - Permutations with Dups/permWithDups.js rename to chapter08RecursionDynamic/8.08 - Permutations with Dups/permWithDups.js diff --git a/chapter08/8.09 - Parens/parens.js b/chapter08RecursionDynamic/8.09 - Parens/parens.js similarity index 100% rename from chapter08/8.09 - Parens/parens.js rename to chapter08RecursionDynamic/8.09 - Parens/parens.js diff --git a/chapter08/8.10 - Paint Fill/paintFill.js b/chapter08RecursionDynamic/8.10 - Paint Fill/paintFill.js similarity index 100% rename from chapter08/8.10 - Paint Fill/paintFill.js rename to chapter08RecursionDynamic/8.10 - Paint Fill/paintFill.js diff --git a/chapter08/8.11 - Coins/coins.js b/chapter08RecursionDynamic/8.11 - Coins/coins.js similarity index 100% rename from chapter08/8.11 - Coins/coins.js rename to chapter08RecursionDynamic/8.11 - Coins/coins.js diff --git a/chapter08/8.12 - Eight Queens/nQueens.js b/chapter08RecursionDynamic/8.12 - Eight Queens/nQueens.js similarity index 100% rename from chapter08/8.12 - Eight Queens/nQueens.js rename to chapter08RecursionDynamic/8.12 - Eight Queens/nQueens.js diff --git a/chapter08/8.13 - Stack Boxes/stackBoxes.js b/chapter08RecursionDynamic/8.13 - Stack Boxes/stackBoxes.js similarity index 100% rename from chapter08/8.13 - Stack Boxes/stackBoxes.js rename to chapter08RecursionDynamic/8.13 - Stack Boxes/stackBoxes.js diff --git a/chapter08/8.14 - Boolean Eval/booleanEval.js b/chapter08RecursionDynamic/8.14 - Boolean Eval/booleanEval.js similarity index 100% rename from chapter08/8.14 - Boolean Eval/booleanEval.js rename to chapter08RecursionDynamic/8.14 - Boolean Eval/booleanEval.js diff --git a/chapter09/9.1 - Stock Data/stockData.md b/chapter09SystemDesign/9.1 - Stock Data/stockData.md similarity index 100% rename from chapter09/9.1 - Stock Data/stockData.md rename to chapter09SystemDesign/9.1 - Stock Data/stockData.md diff --git a/chapter09/9.2 - Social Network/socialNetwork.md b/chapter09SystemDesign/9.2 - Social Network/socialNetwork.md similarity index 100% rename from chapter09/9.2 - Social Network/socialNetwork.md rename to chapter09SystemDesign/9.2 - Social Network/socialNetwork.md diff --git a/chapter09/9.3 - Web Crawler/webCrawler.md b/chapter09SystemDesign/9.3 - Web Crawler/webCrawler.md similarity index 100% rename from chapter09/9.3 - Web Crawler/webCrawler.md rename to chapter09SystemDesign/9.3 - Web Crawler/webCrawler.md diff --git a/chapter09/9.4 - Duplicate URLs/duplicateURLs.md b/chapter09SystemDesign/9.4 - Duplicate URLs/duplicateURLs.md similarity index 100% rename from chapter09/9.4 - Duplicate URLs/duplicateURLs.md rename to chapter09SystemDesign/9.4 - Duplicate URLs/duplicateURLs.md diff --git a/chapter09/9.5 - Cache/cache.md b/chapter09SystemDesign/9.5 - Cache/cache.md similarity index 100% rename from chapter09/9.5 - Cache/cache.md rename to chapter09SystemDesign/9.5 - Cache/cache.md diff --git a/chapter09/9.6 - Sales Rank/salesRank.md b/chapter09SystemDesign/9.6 - Sales Rank/salesRank.md similarity index 100% rename from chapter09/9.6 - Sales Rank/salesRank.md rename to chapter09SystemDesign/9.6 - Sales Rank/salesRank.md diff --git a/chapter09/9.7 - Personal Financial Manager/personalFinancialManager.md b/chapter09SystemDesign/9.7 - Personal Financial Manager/personalFinancialManager.md similarity index 100% rename from chapter09/9.7 - Personal Financial Manager/personalFinancialManager.md rename to chapter09SystemDesign/9.7 - Personal Financial Manager/personalFinancialManager.md diff --git a/chapter09/9.8 - Paste Bin/pasteBins.md b/chapter09SystemDesign/9.8 - Paste Bin/pasteBins.md similarity index 100% rename from chapter09/9.8 - Paste Bin/pasteBins.md rename to chapter09SystemDesign/9.8 - Paste Bin/pasteBins.md diff --git a/chapter09/systemDesignNotes.md b/chapter09SystemDesign/systemDesignNotes.md similarity index 100% rename from chapter09/systemDesignNotes.md rename to chapter09SystemDesign/systemDesignNotes.md diff --git a/chapter10/10.01 - Sorted Merge/sortedMerge.js b/chapter10SortingSearching/10.01 - Sorted Merge/sortedMerge.js similarity index 100% rename from chapter10/10.01 - Sorted Merge/sortedMerge.js rename to chapter10SortingSearching/10.01 - Sorted Merge/sortedMerge.js diff --git a/chapter10/10.02 - Group Anagrams/groupAnagrams.js b/chapter10SortingSearching/10.02 - Group Anagrams/groupAnagrams.js similarity index 100% rename from chapter10/10.02 - Group Anagrams/groupAnagrams.js rename to chapter10SortingSearching/10.02 - Group Anagrams/groupAnagrams.js diff --git a/chapter10/10.03 - Search In Rotated Array/searchInRotatedArray.js b/chapter10SortingSearching/10.03 - Search In Rotated Array/searchInRotatedArray.js similarity index 100% rename from chapter10/10.03 - Search In Rotated Array/searchInRotatedArray.js rename to chapter10SortingSearching/10.03 - Search In Rotated Array/searchInRotatedArray.js diff --git a/chapter10/10.04 - Sorted Search No Size/listy.js b/chapter10SortingSearching/10.04 - Sorted Search No Size/listy.js similarity index 100% rename from chapter10/10.04 - Sorted Search No Size/listy.js rename to chapter10SortingSearching/10.04 - Sorted Search No Size/listy.js diff --git a/chapter10/10.04 - Sorted Search No Size/sortedSearchNoSize.js b/chapter10SortingSearching/10.04 - Sorted Search No Size/sortedSearchNoSize.js similarity index 100% rename from chapter10/10.04 - Sorted Search No Size/sortedSearchNoSize.js rename to chapter10SortingSearching/10.04 - Sorted Search No Size/sortedSearchNoSize.js diff --git a/chapter10/10.05 - Sparse Search/sparseSearch.js b/chapter10SortingSearching/10.05 - Sparse Search/sparseSearch.js similarity index 100% rename from chapter10/10.05 - Sparse Search/sparseSearch.js rename to chapter10SortingSearching/10.05 - Sparse Search/sparseSearch.js diff --git a/chapter10/10.06 - Sort Big File/sortBigFile.js b/chapter10SortingSearching/10.06 - Sort Big File/sortBigFile.js similarity index 100% rename from chapter10/10.06 - Sort Big File/sortBigFile.js rename to chapter10SortingSearching/10.06 - Sort Big File/sortBigFile.js diff --git a/chapter10/10.07 - Missing Int/missingInt.js b/chapter10SortingSearching/10.07 - Missing Int/missingInt.js similarity index 100% rename from chapter10/10.07 - Missing Int/missingInt.js rename to chapter10SortingSearching/10.07 - Missing Int/missingInt.js diff --git a/chapter10/10.08 - Find Duplicates/findDuplicates.js b/chapter10SortingSearching/10.08 - Find Duplicates/findDuplicates.js similarity index 100% rename from chapter10/10.08 - Find Duplicates/findDuplicates.js rename to chapter10SortingSearching/10.08 - Find Duplicates/findDuplicates.js diff --git a/chapter10/10.09 - Sorted Matrix Search/sortedMatrixSearch.js b/chapter10SortingSearching/10.09 - Sorted Matrix Search/sortedMatrixSearch.js similarity index 100% rename from chapter10/10.09 - Sorted Matrix Search/sortedMatrixSearch.js rename to chapter10SortingSearching/10.09 - Sorted Matrix Search/sortedMatrixSearch.js diff --git a/chapter10/10.10 - Rank From Stream/rankFromStream.js b/chapter10SortingSearching/10.10 - Rank From Stream/rankFromStream.js similarity index 100% rename from chapter10/10.10 - Rank From Stream/rankFromStream.js rename to chapter10SortingSearching/10.10 - Rank From Stream/rankFromStream.js diff --git a/chapter10/10.11 - Peaks And Valleys/peaksAndValleys.js b/chapter10SortingSearching/10.11 - Peaks And Valleys/peaksAndValleys.js similarity index 100% rename from chapter10/10.11 - Peaks And Valleys/peaksAndValleys.js rename to chapter10SortingSearching/10.11 - Peaks And Valleys/peaksAndValleys.js diff --git a/chapter10/sortingAlgos/quickSort.js b/chapter10SortingSearching/sortingAlgos/quickSort.js similarity index 100% rename from chapter10/sortingAlgos/quickSort.js rename to chapter10SortingSearching/sortingAlgos/quickSort.js