mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
parent
c2bd267816
commit
4cdb85e22d
|
@ -11,8 +11,7 @@ class Stack(object):
|
||||||
self.top = top
|
self.top = top
|
||||||
|
|
||||||
def push(self, data):
|
def push(self, data):
|
||||||
node = Node(data, self.top)
|
self.top = Node(data, self.top)
|
||||||
self.top = node
|
|
||||||
|
|
||||||
def pop(self):
|
def pop(self):
|
||||||
if self.top is None:
|
if self.top is None:
|
||||||
|
|
|
@ -35,7 +35,10 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
"* None"
|
"* If we pop on an empty stack, do we return None?\n",
|
||||||
|
" * Yes\n",
|
||||||
|
"* Can we assume this fits memory?\n",
|
||||||
|
" * Yes"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -197,21 +200,21 @@
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 2",
|
"display_name": "Python 3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python2"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 2
|
"version": 3
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "2.7.10"
|
"version": "3.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
@ -34,7 +34,10 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
"* None"
|
"* If we pop on an empty stack, do we return None?\n",
|
||||||
|
" * Yes\n",
|
||||||
|
"* Can we assume this fits memory?\n",
|
||||||
|
" * Yes"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -148,8 +151,7 @@
|
||||||
" self.top = top\n",
|
" self.top = top\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def push(self, data):\n",
|
" def push(self, data):\n",
|
||||||
" node = Node(data, self.top)\n",
|
" self.top = Node(data, self.top)\n",
|
||||||
" self.top = node\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
" def pop(self):\n",
|
" def pop(self):\n",
|
||||||
" if self.top is None:\n",
|
" if self.top is None:\n",
|
||||||
|
@ -319,7 +321,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.4.3"
|
"version": "3.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user