Merge pull request #374 from zjhiphop/master

(javascript) fix dequeue exception
This commit is contained in:
wangzheng0822 2019-08-26 07:35:45 +08:00 committed by GitHub
commit 3e0fdb76e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,18 +34,18 @@ class CircularQueue {
}
dequeue() {
if(this.head == null) return -1
if (this.head === this.tail) {
const value = this.head.element
this.head = null
return value
} else if (this.head !== null) {
} else {
const value = this.head.element
this.head = this.head.next
this.tail.next = this.head
return value
} else {
return -1
}
}
}
display() {