mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Update queue from stacks challenge (#111)
Update test cases and __init__ method.
This commit is contained in:
parent
12b58ccf9b
commit
2d651a6eca
|
@ -43,6 +43,8 @@
|
|||
"* Does popping from an empty stack result in an exception?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume the user passed in stack index is valid?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume this fits memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
"* Does popping from an empty stack result in an exception?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume the user passed in stack index is valid?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume this fits memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
|
@ -118,8 +120,8 @@
|
|||
" def __init__(self, num_stacks, stack_size):\n",
|
||||
" self.num_stacks = num_stacks\n",
|
||||
" self.stack_size = stack_size\n",
|
||||
" self.stack_pointers = [-1] * num_stacks\n",
|
||||
" self.stack_array = [None] * num_stacks * stack_size\n",
|
||||
" self.stack_pointers = [-1] * self.num_stacks\n",
|
||||
" self.stack_array = [None] * self.num_stacks * self.stack_size\n",
|
||||
"\n",
|
||||
" def abs_index(self, stack_index):\n",
|
||||
" return stack_index * self.stack_size + self.stack_pointers[stack_index]\n",
|
||||
|
|
Loading…
Reference in New Issue
Block a user