├── 1-Getting-Started-with-Data-Structures ├── 2-Nodes │ ├── 1-Nodes │ │ └── README.md │ ├── 2-Nodes-Conceptual-Part-1 │ │ └── README.md │ ├── 3-Nodes-Conceptual-Part-2 │ │ └── README.md │ ├── 5-Nodes-JavaScript-Part-2 │ │ └── README.md │ └── 4-Nodes-JavaScript-Part-1 │ │ ├── 1-Introduction-Nodes-in-JavaScript │ │ ├── Node.js │ │ └── test │ │ │ └── test.js │ │ ├── 2-Node-Methods-Set-Next-Node │ │ └── Node.js │ │ ├── 3-Node-Methods-Set-Next-Node-Validation │ │ ├── test │ │ │ └── test.js │ │ └── Node.js │ │ ├── 4-Node-Methods-Get-Next-Node │ │ └── Node.js │ │ └── 5-Review-Nodes-in-JavaScript │ │ ├── Node.js │ │ └── test │ │ └── test.js └── 1-Introduction-to-Data-Structures │ ├── 2-Why-Data-Structures │ └── README.md │ ├── 3-Data-Structure-Apis │ └── README.md │ └── 1-Pass-the-Technical-Interview-with-JavaScript-Introduction │ └── README.md ├── 2-JavaScript-Linear-Data-Structures └── 1-Singly-Linked-Lists │ ├── 1-Linked-Lists │ └── README.md │ ├── 3-Linked-Lists-Concptual-II │ └── README.md │ ├── 5-Learn-Linked-Lists-JavaScript-II │ └── README.md │ ├── 2-Linked-Lists-Conceptual-I │ ├── 2-Linked-List-Example │ │ └── README.md │ ├── 4-Linked-List-Review │ │ └── README.md │ ├── 1-Linked-List-Introduction │ │ └── README.md │ └── 3-Linked-Lists-Adding-and-Removing-Nodes │ │ └── README.md │ └── 4-Learn-Linked-Lists-JavaScript-I │ ├── 5-Using-the-Linked-List │ ├── seasons.js │ ├── Node.js │ └── LinkedList.js │ ├── 6-Linked-List-Review │ ├── index.js │ ├── Node.js │ └── LinkedList.js │ ├── 1-Constructor-and-Adding-Head │ ├── LinkedList.js │ └── Node.js │ ├── 4-Printing │ ├── Node.js │ └── LinkedList.js │ ├── 2-Adding-to-Tail │ ├── Node.js │ └── LinkedList.js │ └── 3-Removing-the-Head │ ├── Node.js │ └── LinkedList.js └── README.md /1-Getting-Started-with-Data-Structures/2-Nodes/1-Nodes/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/2-Nodes-Conceptual-Part-1/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/3-Nodes-Conceptual-Part-2/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/5-Nodes-JavaScript-Part-2/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/1-Linked-Lists/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/3-Linked-Lists-Concptual-II/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/1-Introduction-to-Data-Structures/2-Why-Data-Structures/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/1-Introduction-to-Data-Structures/3-Data-Structure-Apis/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/5-Learn-Linked-Lists-JavaScript-II/README.md: -------------------------------------------------------------------------------- 1 | No code in this section -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/2-Linked-Lists-Conceptual-I/2-Linked-List-Example/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/2-Linked-Lists-Conceptual-I/4-Linked-List-Review/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/2-Linked-Lists-Conceptual-I/1-Linked-List-Introduction/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/2-Linked-Lists-Conceptual-I/3-Linked-Lists-Adding-and-Removing-Nodes/README.md: -------------------------------------------------------------------------------- 1 | No code in this section. -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/1-Introduction-Nodes-in-JavaScript/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | } 7 | 8 | let firstNode = new Node('Test'); 9 | console.log(firstNode.data); 10 | console.log(firstNode.next); 11 | 12 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/5-Using-the-Linked-List/seasons.js: -------------------------------------------------------------------------------- 1 | const LinkedList = require('./LinkedList'); 2 | 3 | const seasons = new LinkedList(); 4 | seasons.addToHead('summer'); 5 | seasons.addToHead('spring'); 6 | seasons.addToTail('fall'); 7 | seasons.addToTail('winter'); 8 | seasons.printList(); 9 | seasons.removeHead(); 10 | seasons.printList(); 11 | -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/6-Linked-List-Review/index.js: -------------------------------------------------------------------------------- 1 | const LinkedList = require('./LinkedList'); 2 | 3 | const seasons = new LinkedList(); 4 | seasons.printList(); 5 | 6 | seasons.addToHead('summer'); 7 | seasons.addToHead('spring'); 8 | seasons.printList(); 9 | 10 | seasons.addToTail('fall'); 11 | seasons.addToTail('winter'); 12 | seasons.printList(); 13 | 14 | seasons.removeHead(); 15 | seasons.printList(); -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/2-Node-Methods-Set-Next-Node/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | setNextNode(node) { 7 | this.next = node; 8 | }; 9 | } 10 | 11 | const firstNode = new Node('I am an instance of a Node!'); 12 | const secondNode = new Node('Okk'); 13 | firstNode.setNextNode(secondNode); 14 | console.log(firstNode); 15 | 16 | module.exports = Node; -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/3-Node-Methods-Set-Next-Node-Validation/test/test.js: -------------------------------------------------------------------------------- 1 | console.log = function () {}; 2 | const { 3 | expect 4 | } = require('chai'); 5 | 6 | describe('Node instance', function () { 7 | it('should validate the setNextNode class method', function () { 8 | expect(() => require('../Node.js'), 'Check your call to `.setNextNode()`. You should pass an argument that is not an instance of `Node`.').to.throw(); 9 | }); 10 | }); -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/1-Constructor-and-Adding-Head/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | constructor() { 5 | this.head = null; 6 | } 7 | 8 | addToHead(data) { 9 | const newHead = new Node(data); 10 | const currentHead = this.head; 11 | this.head = newHead; 12 | if(currentHead) { 13 | this.head.setNextNode(currentHead); 14 | } 15 | } 16 | } 17 | 18 | module.exports = LinkedList -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/4-Printing/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (!(node instanceof Node)) { 9 | throw new Error('Next node must be a member of the Node class'); 10 | } 11 | this.next = node; 12 | } 13 | 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/2-Adding-to-Tail/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (!(node instanceof Node)) { 9 | throw new Error('Next node must be a member of the Node class'); 10 | } 11 | this.next = node; 12 | } 13 | 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/3-Removing-the-Head/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (!(node instanceof Node)) { 9 | throw new Error('Next node must be a member of the Node class'); 10 | } 11 | this.next = node; 12 | } 13 | 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/5-Using-the-Linked-List/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (!(node instanceof Node)) { 9 | throw new Error('Next node must be a member of the Node class'); 10 | } 11 | this.next = node; 12 | } 13 | 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/1-Constructor-and-Adding-Head/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (!(node instanceof Node)) { 9 | throw new Error('Next node must be a member of the Node class'); 10 | } 11 | this.next = node; 12 | } 13 | 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | module.exports = Node; -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/3-Node-Methods-Set-Next-Node-Validation/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (node instanceof Node || node === null) { 9 | this.next = node; 10 | } else { 11 | throw 'Error'; 12 | } 13 | } 14 | } 15 | 16 | const firstNode = new Node('I am an instance of a Node!'); 17 | firstNode.setNextNode(2); 18 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/6-Linked-List-Review/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (node instanceof Node || node === null) { 9 | this.next = node; 10 | } else { 11 | throw new Error('Next node must be a member of the Node class.'); 12 | } 13 | } 14 | 15 | getNextNode() { 16 | return this.next; 17 | } 18 | } 19 | 20 | module.exports = Node; -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/4-Node-Methods-Get-Next-Node/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (node instanceof Node || node === null) { 9 | this.next = node; 10 | } else { 11 | throw new Error('Next node must be a member of the Node class.'); 12 | } 13 | } 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | const firstNode = new Node('I am an instance of a Node!'); 20 | const secondNode = new Node('I am the next Node!'); 21 | firstNode.setNextNode(secondNode); 22 | console.log(firstNode.getNextNode()); 23 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/2-Adding-to-Tail/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | 5 | constructor() { 6 | this.head = null; 7 | } 8 | 9 | addToHead(data) { 10 | const newHead = new Node(data); 11 | const currentHead = this.head; 12 | this.head = newHead; 13 | if (currentHead) { 14 | this.head.setNextNode(currentHead); 15 | } 16 | } 17 | 18 | addToTail(data) { 19 | let tail = this.head; 20 | if(!tail) { 21 | this.head = new Node(data); 22 | } else { 23 | while(tail.getNextNode()) { 24 | tail = tail.getNextNode(); 25 | } 26 | tail.setNextNode(new Node(data)); 27 | } 28 | } 29 | } 30 | 31 | module.exports = LinkedList; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pass the Technical Interview with JavaScript Skill Path 2 | 3 | The Technical Interview with JavaScript Skill Path is a collection of resources and exercises designed to help you prepare for technical interviews in the field of JavaScript development. It covers a wide range of topics, including computer science fundamentals, data structures and algorithms, and JavaScript-specific concepts such as asynchronous programming and object-oriented programming. The exercises in this Skill Path are meant to provide hands-on practice with these concepts and help you build your problem-solving and coding skills. By working through the exercises and studying the materials in this Skill Path, you can develop a strong foundation of knowledge that will help you succeed in technical interviews and excel as a JavaScript developer. 4 | -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/5-Review-Nodes-in-JavaScript/Node.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.data = data; 4 | this.next = null; 5 | } 6 | 7 | setNextNode(node) { 8 | if (node instanceof Node || node === null) { 9 | this.next = node; 10 | } else { 11 | throw new Error('Next node must be a member of the Node class.'); 12 | } 13 | } 14 | getNextNode() { 15 | return this.next; 16 | } 17 | } 18 | 19 | let vanillaNode = new Node('Vanilla'); 20 | let strawberryNode = new Node('Berry Tasty'); 21 | let coconutNode = new Node('Coconuts for Coconut'); 22 | let currentNode = vanillaNode; 23 | 24 | vanillaNode.setNextNode(strawberryNode); 25 | strawberryNode.setNextNode(coconutNode); 26 | 27 | 28 | while (currentNode !== null) { 29 | console.log(currentNode.data); 30 | currentNode = currentNode.getNextNode(); 31 | }; 32 | 33 | module.exports = Node; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/3-Removing-the-Head/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | 5 | constructor() { 6 | this.head = null; 7 | } 8 | 9 | addToHead(data) { 10 | const newHead = new Node(data); 11 | const currentHead = this.head; 12 | this.head = newHead; 13 | if (currentHead) { 14 | this.head.setNextNode(currentHead); 15 | } 16 | } 17 | 18 | addToTail(data) { 19 | let tail = this.head; 20 | if (!tail) { 21 | this.head = new Node(data); 22 | } else { 23 | while (tail.getNextNode() !== null) { 24 | tail = tail.getNextNode(); 25 | } 26 | tail.setNextNode(new Node(data)); 27 | } 28 | } 29 | 30 | removeHead() { 31 | const removedHead = this.head; 32 | if(!removedHead) return; 33 | this.head = removedHead.getNextNode(); 34 | return removedHead.data; 35 | } 36 | 37 | } 38 | 39 | module.exports = LinkedList; -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/5-Review-Nodes-in-JavaScript/test/test.js: -------------------------------------------------------------------------------- 1 | console.log = function () {}; 2 | const { 3 | expect 4 | } = require('chai'); 5 | const rewire = require('rewire'); 6 | 7 | let userPrint = ''; 8 | console.log = function (logMsg) { 9 | userPrint += logMsg; 10 | }; 11 | 12 | describe('Log', function () { 13 | it('should print out the ice cream nodes data properties in order', function () { 14 | let moduleImport; 15 | try { 16 | moduleImport = rewire('../Node.js'); 17 | } catch (e) { 18 | expect(true, 'We\'re unable find your `Node` class. Try checking your code for syntax errors.').to.equal(false); 19 | } 20 | 21 | const expectedOutput = /Vanilla.*Berry Tasty.*Coconuts for Coconut/; 22 | const matchFound = !!userPrint.match(expectedOutput); 23 | expect(matchFound, 'Check that you are printing the `data` of `currentNode` on each iteration of the `while` loop. The condition should check that the `currentNode` is not `null` and is updated to be the `next` node of the previous `currentNode`.').to.equal(true); 24 | }); 25 | }); -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/2-Nodes/4-Nodes-JavaScript-Part-1/1-Introduction-Nodes-in-JavaScript/test/test.js: -------------------------------------------------------------------------------- 1 | const {expect} = require('chai'); 2 | const rewire = require('rewire'); 3 | const sinon = require('sinon'); 4 | 5 | console.log = sinon.spy(); 6 | 7 | describe('Node instance', function () { 8 | it('should have the `next` property set to `null`', function () { 9 | let moduleImport; 10 | try { 11 | moduleImport = rewire('../Node.js'); 12 | } catch (e) { 13 | expect(true, 'We\'re unable to export your class. Try checking your code for syntax errors.').to.equal(false); 14 | } 15 | 16 | let node; 17 | try { 18 | node = moduleImport.__get__('firstNode'); 19 | } catch (e) { 20 | expect(true, 'Unable to find the `firstNode` variable.').to.equal(false); 21 | } 22 | 23 | // Check next is set to null 24 | expect(node.next, '`this.next` was not set to `null` in the constructor.').to.equal(null); 25 | 26 | // Check user printed string contains the next property 27 | expect(console.log.calledWith(node.next), 'The `next` property was not logged. The log in the terminal should match the next property.').to.equal(true); 28 | }); 29 | }); -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/4-Printing/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | 5 | constructor() { 6 | this.head = null; 7 | } 8 | 9 | addToHead(data) { 10 | const newHead = new Node(data); 11 | const currentHead = this.head; 12 | this.head = newHead; 13 | if (currentHead) { 14 | this.head.setNextNode(currentHead); 15 | } 16 | } 17 | 18 | addToTail(data) { 19 | let tail = this.head; 20 | if (!tail) { 21 | this.head = new Node(data); 22 | } else { 23 | while (tail.getNextNode() !== null) { 24 | tail = tail.getNextNode(); 25 | } 26 | tail.setNextNode(new Node(data)); 27 | } 28 | } 29 | 30 | removeHead() { 31 | const removedHead = this.head; 32 | if (!removedHead) { 33 | return; 34 | } 35 | this.head = removedHead.getNextNode(); 36 | return removedHead.data; 37 | } 38 | 39 | printList() { 40 | let currentNode = this.head; 41 | let output = ' '; 42 | while(currentNode !== null) { 43 | output += `${currentNode.data} `; 44 | currentNode = currentNode.getNextNode(); 45 | } 46 | output += '' 47 | } 48 | } 49 | 50 | module.exports = LinkedList; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/6-Linked-List-Review/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | constructor() { 5 | this.head = null; 6 | } 7 | 8 | addToHead(data) { 9 | const newHead = new Node(data); 10 | const currentHead = this.head; 11 | this.head = newHead; 12 | if (currentHead) { 13 | this.head.setNextNode(currentHead); 14 | } 15 | } 16 | 17 | addToTail(data) { 18 | let tail = this.head; 19 | if (!tail) { 20 | this.head = new Node(data); 21 | } else { 22 | while (tail.getNextNode() !== null) { 23 | tail = tail.getNextNode(); 24 | } 25 | tail.setNextNode(new Node(data)); 26 | } 27 | } 28 | 29 | removeHead() { 30 | const removedHead = this.head; 31 | if (!removedHead) { 32 | return; 33 | } 34 | this.head = removedHead.getNextNode(); 35 | return removedHead.data; 36 | } 37 | 38 | printList() { 39 | let currentNode = this.head; 40 | let output = ' '; 41 | while (currentNode !== null) { 42 | output += currentNode.data + ' '; 43 | currentNode = currentNode.getNextNode(); 44 | } 45 | output += ''; 46 | console.log(output); 47 | } 48 | 49 | } 50 | 51 | module.exports = LinkedList; -------------------------------------------------------------------------------- /2-JavaScript-Linear-Data-Structures/1-Singly-Linked-Lists/4-Learn-Linked-Lists-JavaScript-I/5-Using-the-Linked-List/LinkedList.js: -------------------------------------------------------------------------------- 1 | const Node = require('./Node'); 2 | 3 | class LinkedList { 4 | constructor() { 5 | this.head = null; 6 | } 7 | 8 | addToHead(data) { 9 | const newHead = new Node(data); 10 | const currentHead = this.head; 11 | this.head = newHead; 12 | if (currentHead) { 13 | this.head.setNextNode(currentHead); 14 | } 15 | } 16 | 17 | addToTail(data) { 18 | let tail = this.head; 19 | if (!tail) { 20 | this.head = new Node(data); 21 | } else { 22 | while (tail.getNextNode() !== null) { 23 | tail = tail.getNextNode(); 24 | } 25 | tail.setNextNode(new Node(data)); 26 | } 27 | } 28 | 29 | removeHead() { 30 | const removedHead = this.head; 31 | if (!removedHead) { 32 | return; 33 | } 34 | this.head = removedHead.getNextNode(); 35 | return removedHead.data; 36 | } 37 | 38 | printList() { 39 | let currentNode = this.head; 40 | let output = ' '; 41 | while (currentNode !== null) { 42 | output += currentNode.data + ' '; 43 | currentNode = currentNode.getNextNode(); 44 | } 45 | output += ''; 46 | console.log(output); 47 | } 48 | 49 | } 50 | 51 | module.exports = LinkedList; -------------------------------------------------------------------------------- /1-Getting-Started-with-Data-Structures/1-Introduction-to-Data-Structures/1-Pass-the-Technical-Interview-with-JavaScript-Introduction/README.md: -------------------------------------------------------------------------------- 1 | #Pass the Technical Interview with JavaScript Introduction 2 | 3 | 4 | In this path, you’ll learn the fundamentals of many important computer science concepts, from foundational data structures like linked lists and graphs to important algorithms such as quicksort and Dijkstra’s algorithm. At each step, you’ll first learn the concepts behind the topic before applying them specifically in JavaScript. 5 | 6 | Throughout, you’ll use modern ES6 JavaScript and will build most of your code using class syntax. Classes are a (relatively) recent addition to JavaScript, and they’ll more closely resemble how these data structures would be built in a classic computer science curriculum. They’ll also allow us to use object-oriented programming techniques to implement our data structures. You’ll start out building a basic data-storing Node class, and as you progress, you’ll build many more complex data structures on top of it. 7 | 8 | In addition to building the data structures themselves, you’ll learn about techniques for using them, from different iteration strategies to analyzing the algorithmic complexity of operations. After that, you’ll learn and implement algorithms for efficient searching, sorting, and pathfinding. 9 | 10 | Finally, we’ll discuss some techniques for effectively solving algorithmic technical interview questions, and you’ll practice implementing efficient solutions to some classic technical interview problems 11 | 12 | Ready? Let’s get started learning about data structures! --------------------------------------------------------------------------------