Skip to content

Commit 3d68bdc

Browse files
Update CircularQueue.js
1 parent 702840b commit 3d68bdc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: Data-Structures/Queue/CircularQueue.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ class CircularQueue {
7777

7878
// Displays the length of queue
7979
length() {
80-
return this.queue.length - 1
80+
if (this.queue.length > 0) {
81+
return this.queue.length - 1
82+
} else {
83+
return 0
84+
}
8185
}
8286

8387
// Display the top most value of queue

0 commit comments

Comments
 (0)