fix(learn): Consolidated comments for Coding Interview Prep challenges - part 2 of 2 (#39576)

* fix: consolidate comments for use with the translation dictionary

* fix: added blank line between comments

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: removed unneeded comment

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
Randell Dawson
2020-09-15 12:31:21 -07:00
committed by GitHub
parent 8788ad946b
commit 876d9f3994
50 changed files with 141 additions and 160 deletions

View File

@ -44,9 +44,9 @@ tests:
```js ```js
function bubbleSort(array) { function bubbleSort(array) {
// change code below this line // Only change code below this line
return array; return array;
// change code above this line // Only change code above this line
} }
bubbleSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]); bubbleSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);

View File

@ -42,9 +42,9 @@ tests:
```js ```js
function insertionSort(array) { function insertionSort(array) {
// change code below this line // Only change code below this line
return array; return array;
// change code above this line // Only change code above this line
} }
insertionSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]); insertionSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);

View File

@ -46,10 +46,9 @@ tests:
```js ```js
function mergeSort(array) { function mergeSort(array) {
// change code below this line // Only change code below this line
// change code above this line
return array; return array;
// Only change code above this line
} }
mergeSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]); mergeSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);

View File

@ -10,7 +10,6 @@ forumTopicId: 301615
Here we will move on to an intermediate sorting algorithm: quick sort. Quick sort is an efficient, recursive divide-and-conquer approach to sorting an array. In this method, a pivot value is chosen in the original array. The array is then partitioned into two subarrays of values less than and greater than the pivot value. We then combine the result of recursively calling the quick sort algorithm on both sub-arrays. This continues until the base case of an empty or single-item array is reached, which we return. The unwinding of the recursive calls return us the sorted array. Here we will move on to an intermediate sorting algorithm: quick sort. Quick sort is an efficient, recursive divide-and-conquer approach to sorting an array. In this method, a pivot value is chosen in the original array. The array is then partitioned into two subarrays of values less than and greater than the pivot value. We then combine the result of recursively calling the quick sort algorithm on both sub-arrays. This continues until the base case of an empty or single-item array is reached, which we return. The unwinding of the recursive calls return us the sorted array.
Quick sort is a very efficient sorting method, providing <i>O(nlog(n))</i> performance on average. It is also relatively easy to implement. These attributes make it a popular and useful sorting method. Quick sort is a very efficient sorting method, providing <i>O(nlog(n))</i> performance on average. It is also relatively easy to implement. These attributes make it a popular and useful sorting method.
<strong>Instructions:</strong> Write a function <code>quickSort</code> which takes an array of integers as input and returns an array of these integers in sorted order from least to greatest. While the choice of the pivot value is important, any pivot will do for our purposes here. For simplicity, the first or last element could be used. <strong>Instructions:</strong> Write a function <code>quickSort</code> which takes an array of integers as input and returns an array of these integers in sorted order from least to greatest. While the choice of the pivot value is important, any pivot will do for our purposes here. For simplicity, the first or last element could be used.
<strong>Note:</strong><br>We are calling this function from behind the scenes; the test array we are using is commented out in the editor. Try logging <code>array</code> to see your sorting algorithm in action!
</section> </section>
## Instructions ## Instructions
@ -27,7 +26,7 @@ tests:
testString: assert(typeof quickSort == 'function'); testString: assert(typeof quickSort == 'function');
- text: <code>quickSort</code> should return a sorted array (least to greatest). - text: <code>quickSort</code> should return a sorted array (least to greatest).
testString: assert(isSorted(quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]))); testString: assert(isSorted(quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])));
- text: <code>quickSort</code> should return an array that is unchanged except for order. - text: <code>quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])</code> should return an array that is unchanged except for order.
testString: assert.sameMembers(quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]), [1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]); testString: assert.sameMembers(quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]), [1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]);
- text: <code>quickSort</code> should not use the built-in <code>.sort()</code> method. - text: <code>quickSort</code> should not use the built-in <code>.sort()</code> method.
testString: assert(isBuiltInSortUsed()); testString: assert(isBuiltInSortUsed());
@ -43,14 +42,10 @@ tests:
```js ```js
function quickSort(array) { function quickSort(array) {
// change code below this line // Only change code below this line
// change code above this line
return array; return array;
// Only change code above this line
} }
// test array:
// [1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]
``` ```
</div> </div>
@ -106,9 +101,6 @@ function quickSort(array) {
return [...quickSort(lesser), ...equal, ...quickSort(greater)]; return [...quickSort(lesser), ...equal, ...quickSort(greater)];
} }
} }
// test array:
// [1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]
``` ```
</section> </section>

View File

@ -42,9 +42,9 @@ tests:
```js ```js
function selectionSort(array) { function selectionSort(array) {
// change code below this line // Only change code below this line
return array; return array;
// change code above this line // Only change code above this line
} }

View File

@ -44,7 +44,6 @@ tests:
```js ```js
function updateInventory(arr1, arr2) { function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
return arr1; return arr1;
} }

View File

@ -53,8 +53,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -56,7 +56,6 @@ tests:
```js ```js
function bfs(graph, root) { function bfs(graph, root) {
// Distance object returned
var nodesLen = {}; var nodesLen = {};
return nodesLen; return nodesLen;
@ -112,7 +111,6 @@ function isEquivalent(a, b) {
```js ```js
function bfs(graph, root) { function bfs(graph, root) {
// Distance object returned
var nodesLen = {}; var nodesLen = {};
// Set all distances to infinity // Set all distances to infinity
for (var i = 0; i < graph.length; i++) { for (var i = 0; i < graph.length; i++) {

View File

@ -49,8 +49,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -47,8 +47,9 @@ function BinarySearchTree() {
this.root = null; this.root = null;
} }
function isBinarySearchTree(tree) { function isBinarySearchTree(tree) {
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -56,8 +56,9 @@ var Node = function(data, prev) {
var DoublyLinkedList = function() { var DoublyLinkedList = function() {
this.head = null; this.head = null;
this.tail = null; this.tail = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```

View File

@ -59,8 +59,9 @@ var hash = string => {
}; };
var HashTable = function() { var HashTable = function() {
this.collection = {}; this.collection = {};
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```
@ -105,7 +106,7 @@ var hash = (string) => {
}; };
var HashTable = function() { var HashTable = function() {
this.collection = {}; this.collection = {};
// change code below this line // Only change code below this line
this.add = function(key, val) { this.add = function(key, val) {
var theHash = hash(key); var theHash = hash(key);
@ -133,7 +134,7 @@ var HashTable = function() {
} }
return null return null
} }
// change code above this line // Only change code above this line
}; };
``` ```

View File

@ -58,8 +58,9 @@ tests:
```js ```js
var Map = function() { var Map = function() {
this.collection = {}; this.collection = {};
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```
@ -72,7 +73,7 @@ var Map = function() {
```js ```js
var Map = function() { var Map = function() {
this.collection = {}; this.collection = {};
// change code below this line // Only change code below this line
this.add = function(key,value) { this.add = function(key,value) {
this.collection[key] = value; this.collection[key] = value;
@ -103,7 +104,7 @@ var Map = function() {
delete this.collection[item]; delete this.collection[item];
} }
} }
// change code above this line // Only change code above this line
}; };
``` ```

View File

@ -82,20 +82,14 @@ class Set {
return this.dictionary[element] !== undefined; return this.dictionary[element] !== undefined;
} }
// This method will return all the values in the set as an array // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.keys(this.dictionary);
} }
// change code below this line // Only change code below this line
// write your add method here // Only change code above this line
// write your remove method here
// write your size method here
// change code above this line
} }
``` ```

View File

@ -57,8 +57,9 @@ var Node = function() {
}; };
}; };
var Trie = function() { var Trie = function() {
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```

View File

@ -43,7 +43,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// change code below this line
``` ```
</div> </div>

View File

@ -54,9 +54,9 @@ tests:
```js ```js
function checkSet() { function checkSet() {
var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]); var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]);
// change code below this line // Only change code below this line
// change code above this line // Only change code above this line
console.log(Array.from(set)); console.log(Array.from(set));
return set; return set;
} }

View File

@ -58,7 +58,7 @@ function Node(value) {
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// case 1: target has no children, change code below this line // Only change code below this line
} }
``` ```

View File

@ -61,7 +61,7 @@ function BinarySearchTree() {
} }
var target; var target;
var parent = null; var parent = null;
// find the target value and its parent // Find the target value and its parent
(function findValue(node = this.root) { (function findValue(node = this.root) {
if (value == node.value) { if (value == node.value) {
target = node; target = node;
@ -80,10 +80,10 @@ function BinarySearchTree() {
if (target === null) { if (target === null) {
return null; return null;
} }
// count the children of the target to delete // Count the children of the target to delete
var children = var children =
(target.left !== null ? 1 : 0) + (target.right !== null ? 1 : 0); (target.left !== null ? 1 : 0) + (target.right !== null ? 1 : 0);
// case 1: target has no children // Case 1: Target has no children
if (children === 0) { if (children === 0) {
if (target == this.root) { if (target == this.root) {
this.root = null; this.root = null;
@ -95,7 +95,8 @@ function BinarySearchTree() {
} }
} }
} }
// case 2: target has one child, change code below this line // Case 2: Target has one child
// Only change code below this line
}; };
} }
``` ```

View File

@ -66,7 +66,7 @@ function BinarySearchTree() {
} }
var target; var target;
var parent = null; var parent = null;
// find the target value and its parent // Find the target value and its parent
(function findValue(node = this.root) { (function findValue(node = this.root) {
if (value == node.value) { if (value == node.value) {
target = node; target = node;
@ -85,10 +85,10 @@ function BinarySearchTree() {
if (target === null) { if (target === null) {
return null; return null;
} }
// count the children of the target to delete // Count the children of the target to delete
var children = var children =
(target.left !== null ? 1 : 0) + (target.right !== null ? 1 : 0); (target.left !== null ? 1 : 0) + (target.right !== null ? 1 : 0);
// case 1: target has no children // Case 1: Target has no children
if (children === 0) { if (children === 0) {
if (target == this.root) { if (target == this.root) {
this.root = null; this.root = null;
@ -100,7 +100,7 @@ function BinarySearchTree() {
} }
} }
} }
// case 2: target has one child // Case 2: Target has one child
else if (children == 1) { else if (children == 1) {
var newChild = target.left !== null ? target.left : target.right; var newChild = target.left !== null ? target.left : target.right;
if (parent === null) { if (parent === null) {
@ -114,7 +114,8 @@ function BinarySearchTree() {
} }
target = null; target = null;
} }
// case 3: target has two children, change code below this line // Case 3: Target has two children
// Only change code below this line
}; };
} }
``` ```

View File

@ -55,8 +55,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```
@ -117,8 +118,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
this.findMinHeight = function(root = this.root) { this.findMinHeight = function(root = this.root) {
// empty tree. // empty tree.
if (root === null) { if (root === null) {

View File

@ -50,8 +50,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -41,22 +41,22 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// check if array is sorted
function isSorted(a){ function isSorted(a){
for(let i = 0; i < a.length - 1; i++) for(let i = 0; i < a.length - 1; i++)
if(a[i] > a[i + 1]) if(a[i] > a[i + 1])
return false; return false;
return true; return true;
} }
// generate a randomly filled array // Generate a randomly filled array
var array = new Array(); var array = new Array();
(function createArray(size = 5) { (function createArray(size = 5) {
array.push(+(Math.random() * 100).toFixed(0)); array.push(+(Math.random() * 100).toFixed(0));
return size > 1 ? createArray(size - 1) : undefined; return size > 1 ? createArray(size - 1) : undefined;
})(25); })(25);
var MinHeap = function() { var MinHeap = function() {
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```

View File

@ -55,8 +55,9 @@ tests:
```js ```js
var MaxHeap = function() { var MaxHeap = function() {
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```
@ -68,7 +69,7 @@ var MaxHeap = function() {
```js ```js
var MaxHeap = function() { var MaxHeap = function() {
// change code below this line // Only change code below this line
this.heap = [null]; this.heap = [null];
this.insert = (ele) => { this.insert = (ele) => {
var index = this.heap.length; var index = this.heap.length;
@ -84,7 +85,7 @@ var MaxHeap = function() {
this.print = () => { this.print = () => {
return this.heap.slice(1); return this.heap.slice(1);
} }
// change code above this line // Only change code above this line
}; };
``` ```

View File

@ -46,8 +46,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```
@ -127,7 +128,7 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
this.invert = function(node = this.root) { this.invert = function(node = this.root) {
if (node) { if (node) {
const temp = node.left; const temp = node.left;
@ -138,7 +139,7 @@ function BinarySearchTree() {
} }
return node; return node;
} }
// change code above this line // Only change code above this line
} }
``` ```

View File

@ -42,15 +42,15 @@ class Set {
this.dictionary = {}; this.dictionary = {};
this.length = 0; this.length = 0;
} }
// this method will check for the presence of an element and return true or false // This method will check for the presence of an element and return true or false
has(element) { has(element) {
return this.dictionary[element] !== undefined; return this.dictionary[element] !== undefined;
} }
// this method will return all the values in the set // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.keys(this.dictionary);
} }
// this method will add an element to the set // This method will add an element to the set
add(element) { add(element) {
if (!this.has(element)) { if (!this.has(element)) {
this.dictionary[element] = true; this.dictionary[element] = true;
@ -60,7 +60,7 @@ class Set {
return false; return false;
} }
// this method will remove an element from a set // This method will remove an element from a set
remove(element) { remove(element) {
if (this.has(element)) { if (this.has(element)) {
delete this.dictionary[element]; delete this.dictionary[element];
@ -70,11 +70,11 @@ class Set {
return false; return false;
} }
// this method will return the size of the set // This method will return the size of the set
size() { size() {
return this.length; return this.length;
} }
// This is our union method from that lesson // This is our union method
union(set) { union(set) {
const newSet = new Set(); const newSet = new Set();
this.values().forEach(value => { this.values().forEach(value => {
@ -86,7 +86,7 @@ class Set {
return newSet; return newSet;
} }
// This is our intersection method from that lesson // This is our intersection method
intersection(set) { intersection(set) {
const newSet = new Set(); const newSet = new Set();
@ -108,8 +108,9 @@ class Set {
return newSet; return newSet;
} }
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -49,15 +49,15 @@ class Set {
this.dictionary = {}; this.dictionary = {};
this.length = 0; this.length = 0;
} }
// this method will check for the presence of an element and return true or false // This method will check for the presence of an element and return true or false
has(element) { has(element) {
return this.dictionary[element] !== undefined; return this.dictionary[element] !== undefined;
} }
// this method will return all the values in the set // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.keys(this.dictionary);
} }
// this method will add an element to the set // This method will add an element to the set
add(element) { add(element) {
if (!this.has(element)) { if (!this.has(element)) {
this.dictionary[element] = true; this.dictionary[element] = true;
@ -67,7 +67,7 @@ class Set {
return false; return false;
} }
// this method will remove an element from a set // This method will remove an element from a set
remove(element) { remove(element) {
if (this.has(element)) { if (this.has(element)) {
delete this.dictionary[element]; delete this.dictionary[element];
@ -77,11 +77,11 @@ class Set {
return false; return false;
} }
// this method will return the size of the set // This method will return the size of the set
size() { size() {
return this.length; return this.length;
} }
// This is our union method from that lesson // This is our union method
union(set) { union(set) {
const newSet = new Set(); const newSet = new Set();
this.values().forEach(value => { this.values().forEach(value => {
@ -93,7 +93,7 @@ class Set {
return newSet; return newSet;
} }
// This is our intersection method from that lesson // This is our intersection method
intersection(set) { intersection(set) {
const newSet = new Set(); const newSet = new Set();
@ -115,7 +115,7 @@ class Set {
return newSet; return newSet;
} }
// This is our difference method from that lesson
difference(set) { difference(set) {
const newSet = new Set(); const newSet = new Set();
@ -127,8 +127,9 @@ class Set {
return newSet; return newSet;
} }
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -40,15 +40,15 @@ class Set {
this.dictionary = {}; this.dictionary = {};
this.length = 0; this.length = 0;
} }
// this method will check for the presence of an element and return true or false // This method will check for the presence of an element and return true or false
has(element) { has(element) {
return this.dictionary[element] !== undefined; return this.dictionary[element] !== undefined;
} }
// this method will return all the values in the set // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.keys(this.dictionary);
} }
// this method will add an element to the set // This method will add an element to the set
add(element) { add(element) {
if (!this.has(element)) { if (!this.has(element)) {
this.dictionary[element] = true; this.dictionary[element] = true;
@ -58,7 +58,7 @@ class Set {
return false; return false;
} }
// this method will remove an element from a set // This method will remove an element from a set
remove(element) { remove(element) {
if (this.has(element)) { if (this.has(element)) {
delete this.dictionary[element]; delete this.dictionary[element];
@ -68,13 +68,13 @@ class Set {
return false; return false;
} }
// this method will return the size of the set // This method will return the size of the set
size() { size() {
return this.length; return this.length;
} }
// change code below this line // Only change code below this line
// change code above this line // Only change code above this line
} }
``` ```

View File

@ -41,15 +41,15 @@ class Set {
this.dictionary = {}; this.dictionary = {};
this.length = 0; this.length = 0;
} }
// this method will check for the presence of an element and return true or false // This method will check for the presence of an element and return true or false
has(element) { has(element) {
return this.dictionary[element] !== undefined; return this.dictionary[element] !== undefined;
} }
// this method will return all the values in the set // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.keys(this.dictionary);
} }
// this method will add an element to the set // This method will add an element to the set
add(element) { add(element) {
if (!this.has(element)) { if (!this.has(element)) {
this.dictionary[element] = true; this.dictionary[element] = true;
@ -59,7 +59,7 @@ class Set {
return false; return false;
} }
// this method will remove an element from a set // This method will remove an element from a set
remove(element) { remove(element) {
if (this.has(element)) { if (this.has(element)) {
delete this.dictionary[element]; delete this.dictionary[element];
@ -69,11 +69,11 @@ class Set {
return false; return false;
} }
// this method will return the size of the set // This method will return the size of the set
size() { size() {
return this.length; return this.length;
} }
// This is our union method from that lesson // This is our union method
union(set) { union(set) {
const newSet = new Set(); const newSet = new Set();
this.values().forEach(value => { this.values().forEach(value => {
@ -85,8 +85,9 @@ class Set {
return newSet; return newSet;
} }
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -61,9 +61,9 @@ var MaxHeap = function() {
this.print = () => { this.print = () => {
return this.heap.slice(1); return this.heap.slice(1);
} }
// change code below this line // Only change code below this line
// change code above this line // Only change code above this line
}; };
``` ```

View File

@ -52,7 +52,7 @@ function LinkedList() {
var length = 0; var length = 0;
var head = null; var head = null;
var Node = function(element){ // {1} var Node = function(element){
this.element = element; this.element = element;
this.next = null; this.next = null;
}; };
@ -100,7 +100,7 @@ function LinkedList() {
var length = 0; var length = 0;
var head = null; var head = null;
var Node = function (element) { // {1} var Node = function (element) {
this.element = element; this.element = element;
this.next = null; this.next = null;
}; };

View File

@ -43,10 +43,7 @@ tests:
```js ```js
function checkSet(){ function checkSet(){
var set = //Create a set with values 1, 2, 3, 4, & 5 var set = null;
//Remove the value 2
//Remove the value 5
//Return the set
return set; return set;
} }
``` ```

View File

@ -49,8 +49,9 @@ var Node = function(data, prev) {
var DoublyLinkedList = function() { var DoublyLinkedList = function() {
this.head = null; this.head = null;
this.tail = null; this.tail = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
}; };
``` ```

View File

@ -55,7 +55,7 @@ function LinkedList() {
var length = 0; var length = 0;
var head = null; var head = null;
var Node = function(element){ // {1} var Node = function(element){
this.element = element; this.element = element;
this.next = null; this.next = null;
}; };
@ -120,7 +120,7 @@ function LinkedList() {
var length = 0; var length = 0;
var head = null; var head = null;
var Node = function(element){ // {1} var Node = function(element){
this.element = element; this.element = element;
this.next = null; this.next = null;
}; };

View File

@ -40,13 +40,11 @@ tests:
```js ```js
function checkSet(arrToBeSet, checkValue){ function checkSet(arrToBeSet, checkValue){
// change code below this line // Only change code below this line
// change code above this line // Only change code above this line
} }
checkSet([ 1, 2, 3], 2); // Should return [ true, 3 ]
``` ```
</div> </div>

View File

@ -53,8 +53,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```
@ -114,7 +115,7 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
this.levelOrder = (root = this.root) => { this.levelOrder = (root = this.root) => {
if(!root) return null; if(!root) return null;
let queue = [root]; let queue = [root];
@ -140,7 +141,7 @@ function BinarySearchTree() {
} }
return results; return results;
} }
// change code above this line // Only change code above this line
} }
``` ```

View File

@ -65,8 +65,9 @@ function Node(value) {
} }
function BinarySearchTree() { function BinarySearchTree() {
this.root = null; this.root = null;
// change code below this line // Only change code below this line
// change code above this line
// Only change code above this line
} }
``` ```

View File

@ -44,9 +44,9 @@ tests:
```js ```js
function checkSet(set){ function checkSet(set){
// change code below this line // Only change code below this line
// change code above this line // Only change code above this line
} }
``` ```

View File

@ -44,10 +44,9 @@ var Kitten = new Node('Kitten');
var Puppy = new Node('Puppy'); var Puppy = new Node('Puppy');
Kitten.next = Puppy; Kitten.next = Puppy;
// only add code below this line // Only change code below this line
// test your code
console.log(Kitten.next);
``` ```
</div> </div>

View File

@ -61,7 +61,6 @@ primeSummation(2000000);
<section id='solution'> <section id='solution'>
```js ```js
//noprotect
function primeSummation(n) { function primeSummation(n) {
if (n < 3) { return 0 }; if (n < 3) { return 0 };
let nums = [0, 0, 2]; let nums = [0, 0, 2];

View File

@ -59,11 +59,9 @@ tests:
```js ```js
function fiboEvenSum(n) { function fiboEvenSum(n) {
// You can do it!
return true; return true;
} }
fiboEvenSum(10);
``` ```
</div> </div>

View File

@ -132,8 +132,6 @@ function replaceChar(origString, replaceChar, index) {
```js ```js
// noprotect
function solve24(numStr) { function solve24(numStr) {
const digitsArr = numStr.split(''); const digitsArr = numStr.split('');
const answers = []; const answers = [];

View File

@ -64,7 +64,6 @@ function emirps(n) {
```js ```js
// noprotect
function emirps(num, showEmirps) function emirps(num, showEmirps)
{ {
const is_prime = function(n) const is_prime = function(n)

View File

@ -65,7 +65,6 @@ function primeGenerator(num, showPrimes) {
```js ```js
// noprotect
function primeGenerator(num, showPrimes) { function primeGenerator(num, showPrimes) {
let i, let i,
arr = []; arr = [];

View File

@ -50,7 +50,6 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// noprotect
function hailstoneSequence() { function hailstoneSequence() {
const res = []; const res = [];
@ -78,7 +77,6 @@ const res = [[27, 82, 41, 124, 8, 4, 2, 1], [351, 77031]];
```js ```js
// noprotect
function hailstoneSequence () { function hailstoneSequence () {
const res = []; const res = [];

View File

@ -43,7 +43,7 @@ function isHarshadOrNiven() {
firstTwenty: [], firstTwenty: [],
firstOver1000: undefined firstOver1000: undefined
}; };
// Change after this line // Only change code below this line
return res; return res;
} }

View File

@ -50,7 +50,6 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// noprotect
function heronianTriangle(n) { function heronianTriangle(n) {
@ -84,7 +83,6 @@ const res = [
```js ```js
// noprotect
function heronianTriangle(n) { function heronianTriangle(n) {
const list = []; const list = [];
const result = []; const result = [];

View File

@ -71,7 +71,6 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// noprotect
function ffr(n) { function ffr(n) {
return n; return n;
} }
@ -102,7 +101,6 @@ const ffsParamRes = [[10, 14], [50, 59], [100, 112], [1000, 1041]];
```js ```js
// noprotect
const R = [null, 1]; const R = [null, 1];
const S = [null, 2]; const S = [null, 2];

View File

@ -51,7 +51,6 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
// noprotect
function splitCoconuts(intSailors) { function splitCoconuts(intSailors) {
return true; return true;
@ -69,7 +68,6 @@ function splitCoconuts(intSailors) {
```js ```js
// noprotect
function splitCoconuts(intSailors) { function splitCoconuts(intSailors) {
let intNuts = intSailors; let intNuts = intSailors;
let result = splitCoconutsHelper(intNuts, intSailors); let result = splitCoconutsHelper(intNuts, intSailors);