mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-07 09:58:03 +00:00
Added queue challenge.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
# Need to avoid naming this queue.py as it
|
||||
# will conflict with IPython Notebook
|
||||
|
||||
class Node(object):
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
self.next = None
|
||||
|
||||
class Queue(object):
|
||||
|
||||
def __init__(self):
|
||||
self.first = None
|
||||
self.last = None
|
||||
@@ -24,6 +23,7 @@ class Queue(object):
|
||||
# Empty list
|
||||
if self.first is None and self.last is None:
|
||||
return None
|
||||
|
||||
# Remove only element from a one element list
|
||||
elif self.first == self.last:
|
||||
data = self.first.data
|
||||
|
||||
Reference in New Issue
Block a user