mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
@@ -39,6 +39,8 @@
|
||||
"* Can you have duplicate values like 5, 5?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume this fits memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
@@ -191,7 +193,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"version": "3.5.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
"* Can you have duplicate values like 5, 5?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume this fits memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
@@ -87,8 +89,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../stack/stack.py\n",
|
||||
"%load ../stack/stack.py"
|
||||
"%run ../stack/stack.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -108,7 +109,7 @@
|
||||
" if buff.is_empty() or temp >= buff.peek():\n",
|
||||
" buff.push(temp)\n",
|
||||
" else:\n",
|
||||
" while not buff.is_empty() and buff.peek() > temp:\n",
|
||||
" while not buff.is_empty() and temp < buff.peek():\n",
|
||||
" self.push(buff.pop())\n",
|
||||
" buff.push(temp)\n",
|
||||
" return buff"
|
||||
@@ -135,7 +136,7 @@
|
||||
" buff = MyStack()\n",
|
||||
" while not self.is_empty():\n",
|
||||
" temp = self.pop()\n",
|
||||
" while not buff.is_empty() and buff.peek() > temp:\n",
|
||||
" while not buff.is_empty() and temp < buff.peek():\n",
|
||||
" self.push(buff.pop())\n",
|
||||
" buff.push(temp)\n",
|
||||
" return buff"
|
||||
@@ -252,7 +253,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