diff --git a/stacks_queues/set_of_stacks/set_of_stacks_solution.ipynb b/stacks_queues/set_of_stacks/set_of_stacks_solution.ipynb index f476670..e65df05 100644 --- a/stacks_queues/set_of_stacks/set_of_stacks_solution.ipynb +++ b/stacks_queues/set_of_stacks/set_of_stacks_solution.ipynb @@ -136,6 +136,9 @@ " def is_full(self):\n", " return self.num_items == self.capacity\n", "\n", + " def is_empty(self):\n", + " return self.num_items == 0\n", + "\n", "\n", "class SetOfStacks(object):\n", "\n", @@ -154,10 +157,9 @@ " if self.last_stack is None:\n", " return None\n", " data = self.last_stack.pop()\n", - " if not self.last_stack.num_items:\n", + " if self.last_stack.is_empty():\n", " self.stacks.pop()\n", - " self.last_stack = self.stacks[-1] \\\n", - " if len(self.stacks) else None\n", + " self.last_stack = self.stacks[-1] if self.stacks else None\n", " return data" ] },