Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
non-stretch solution
  • Loading branch information
estoup committed Oct 23, 2020
commit 1dff0bfc1aadba38be6a2bf76b4530835e6a07d5
2 changes: 2 additions & 0 deletions python/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def enqueue(self, data):

def dequeue(self):
# write your code to removes the data to the Queue following FIFO and return the Queue
if not self.queue:
return 'Nothing to dequeue'
self.queue.pop(0)
self.total -= 1
return self.queue
Expand Down
19 changes: 14 additions & 5 deletions python/stack.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
class Stack:
# write your __init__ method here that should store a 'total' value which is the total number of elements in the Stack and a 'stack' value which is an array of stored values in the Stack
def __init__(self):
self.total = 0
self.stack = []

def push(self):
def push(self, data):
# write your code to add data following LIFO and return the Stack
pass
self.stack.append(data)
self.total += 1
return self.stack

def pop(self, data):
def pop(self):
# write your code to removes the data following LIFO and return the Stack
pass
if not self.stack:
return 'Nothing to pop'
self.stack.pop()
self.total -= 1
return self.stack

def size(self):
# write your code that returns the size of the Stack
pass
return self.total