From 314144fae69100c9cf03845434c801f72e4d7714 Mon Sep 17 00:00:00 2001 From: Martin Beacham Date: Wed, 3 Apr 2024 11:25:30 -0400 Subject: [PATCH] Update CircularQueue.js for zero-length case (#1655) * Update CircularQueue.js * Update CircularQueue.js Taking comments into account for refactoring my change. * Update CircularQueue.js Adding "this" to checkEmpty() --- Data-Structures/Queue/CircularQueue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data-Structures/Queue/CircularQueue.js b/Data-Structures/Queue/CircularQueue.js index 27f219678..c71625166 100644 --- a/Data-Structures/Queue/CircularQueue.js +++ b/Data-Structures/Queue/CircularQueue.js @@ -77,7 +77,7 @@ class CircularQueue { // Displays the length of queue length() { - return this.queue.length - 1 + return this.checkEmpty() ? 0 : this.queue.length - 1 } // Display the top most value of queue