Standardize indent size in Data Structures challenge seeds (#38803)
* Standardize indent size in "Priority Queue" seed * Standardize indent size in "Circular Queue" seed * Standardize indent size * Standardize indents "Search within a Linked List" * Standardize indents "Remove Elements from a Linked List by Index"
This commit is contained in:
@ -80,34 +80,34 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
class CircularQueue {
|
class CircularQueue {
|
||||||
constructor(size) {
|
constructor(size) {
|
||||||
|
|
||||||
this.queue = [];
|
this.queue = [];
|
||||||
this.read = 0;
|
this.read = 0;
|
||||||
this.write = 0;
|
this.write = 0;
|
||||||
this.max = size - 1;
|
this.max = size - 1;
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
this.queue.push(null);
|
this.queue.push(null);
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print() {
|
print() {
|
||||||
return this.queue;
|
return this.queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
enqueue(item) {
|
enqueue(item) {
|
||||||
// Only change code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
|
|
||||||
dequeue() {
|
dequeue() {
|
||||||
// Only change code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function PriorityQueue () {
|
function PriorityQueue () {
|
||||||
this.collection = [];
|
this.collection = [];
|
||||||
this.printCollection = function() {
|
this.printCollection = function() {
|
||||||
console.log(this.collection);
|
console.log(this.collection);
|
||||||
};
|
};
|
||||||
// Only change code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -69,15 +69,15 @@ function LinkedList() {
|
|||||||
this.add = function(element){
|
this.add = function(element){
|
||||||
var node = new Node(element);
|
var node = new Node(element);
|
||||||
if(head === null){
|
if(head === null){
|
||||||
head = node;
|
head = node;
|
||||||
} else {
|
} else {
|
||||||
var currentNode = head;
|
var currentNode = head;
|
||||||
|
|
||||||
while(currentNode.next){
|
while(currentNode.next){
|
||||||
currentNode = currentNode.next;
|
currentNode = currentNode.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentNode.next = node;
|
currentNode.next = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
length++;
|
length++;
|
||||||
|
@ -67,13 +67,13 @@ function LinkedList() {
|
|||||||
if(head === null){
|
if(head === null){
|
||||||
head = node;
|
head = node;
|
||||||
} else {
|
} else {
|
||||||
var currentNode = head;
|
var currentNode = head;
|
||||||
|
|
||||||
while(currentNode.next){
|
while(currentNode.next){
|
||||||
currentNode = currentNode.next;
|
currentNode = currentNode.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentNode.next = node;
|
currentNode.next = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
length++;
|
length++;
|
||||||
|
@ -74,13 +74,13 @@ function LinkedList() {
|
|||||||
if(head === null){
|
if(head === null){
|
||||||
head = node;
|
head = node;
|
||||||
} else {
|
} else {
|
||||||
var currentNode = head;
|
var currentNode = head;
|
||||||
|
|
||||||
while(currentNode.next){
|
while(currentNode.next){
|
||||||
currentNode = currentNode.next;
|
currentNode = currentNode.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentNode.next = node;
|
currentNode.next = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
length++;
|
length++;
|
||||||
@ -90,14 +90,14 @@ function LinkedList() {
|
|||||||
var currentNode = head;
|
var currentNode = head;
|
||||||
var previousNode;
|
var previousNode;
|
||||||
if(currentNode.element === element){
|
if(currentNode.element === element){
|
||||||
head = currentNode.next;
|
head = currentNode.next;
|
||||||
} else {
|
} else {
|
||||||
while(currentNode.element !== element) {
|
while(currentNode.element !== element) {
|
||||||
previousNode = currentNode;
|
previousNode = currentNode;
|
||||||
currentNode = currentNode.next;
|
currentNode = currentNode.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
previousNode.next = currentNode.next;
|
previousNode.next = currentNode.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
length --;
|
length --;
|
||||||
|
Reference in New Issue
Block a user