mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 01:18:02 +00:00
Polish set of stacks challenge and solution (#73)
Update constraints, algorithm discussion, and code.
This commit is contained in:
@@ -36,9 +36,15 @@
|
||||
"\n",
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
" * Yes\n",
|
||||
"* Are all stack bound by the same capacity?\n",
|
||||
" * Yes\n",
|
||||
"* If a stack becomes full, should automatically create one?\n",
|
||||
" * Yes\n",
|
||||
"* If a stack becomes empty, should we delete it?\n",
|
||||
" * Yes\n",
|
||||
"* If we pop on an empty stack, should we return None?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume this fits memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
@@ -111,7 +117,7 @@
|
||||
"\n",
|
||||
"class SetOfStacks(object):\n",
|
||||
"\n",
|
||||
" def __init__(self, capacity):\n",
|
||||
" def __init__(self, indiv_stack_capacity):\n",
|
||||
" # TODO: Implement me\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
@@ -151,7 +157,7 @@
|
||||
"\n",
|
||||
" def test_set_of_stacks(self):\n",
|
||||
" print('Test: Push on an empty stack')\n",
|
||||
" stacks = SetOfStacks(capacity=2)\n",
|
||||
" stacks = SetOfStacks(indiv_stack_capacity=2)\n",
|
||||
" stacks.push(3)\n",
|
||||
"\n",
|
||||
" print('Test: Push on a non-empty stack')\n",
|
||||
@@ -208,7 +214,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"version": "3.5.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user