Update and rename circular_queue_II.py to circular_queue_list.py

This commit is contained in:
marina 2023-08-07 18:05:28 -07:00 committed by GitHub
parent 71ca605489
commit afe695c69f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# author: bt3gl
class CircularQueue:
def __init__(self, k: int):
@ -14,7 +15,6 @@ class CircularQueue:
return (end + 1) % self.size
def enqueue(self, value: int) -> bool:
if self.is_full():
return False
@ -23,11 +23,9 @@ class CircularQueue:
self.tail = self._get_next_position(self.tail)
self.queue[self.tail] = value
return True
def dequeue(self) -> bool:
if self.is_empty():
return False
@ -37,15 +35,14 @@ class CircularQueue:
return True
self.head = self._get_next_position(self.head)
return True
def Front(self) -> int:
def front(self) -> int:
if self.is_empty():
return -1
return self.queue[self.head]
def Rear(self) -> int:
def rear(self) -> int:
if self.is_empty():
return -1
return self.queue[self.tail]