Update stack min challenge (#108)

Updates constraints and solution.
This commit is contained in:
Donne Martin 2016-10-26 07:57:51 -04:00 committed by GitHub
parent cf337334a5
commit 0bf56834c0
2 changed files with 9 additions and 6 deletions

View File

@ -39,6 +39,8 @@
"* Can you have duplicate values like 5, 5?\n", "* Can you have duplicate values like 5, 5?\n",
" * Yes\n", " * Yes\n",
"* Can we assume we already have a stack class that can be used for this problem?\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" " * Yes"
] ]
}, },
@ -191,7 +193,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,

View File

@ -38,6 +38,8 @@
"* Can you have duplicate values like 5, 5?\n", "* Can you have duplicate values like 5, 5?\n",
" * Yes\n", " * Yes\n",
"* Can we assume we already have a stack class that can be used for this problem?\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" " * Yes"
] ]
}, },
@ -87,8 +89,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"%run ../stack/stack.py\n", "%run ../stack/stack.py"
"%load ../stack/stack.py"
] ]
}, },
{ {
@ -108,7 +109,7 @@
" if buff.is_empty() or temp >= buff.peek():\n", " if buff.is_empty() or temp >= buff.peek():\n",
" buff.push(temp)\n", " buff.push(temp)\n",
" else:\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", " self.push(buff.pop())\n",
" buff.push(temp)\n", " buff.push(temp)\n",
" return buff" " return buff"
@ -135,7 +136,7 @@
" buff = MyStack()\n", " buff = MyStack()\n",
" while not self.is_empty():\n", " while not self.is_empty():\n",
" temp = self.pop()\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", " self.push(buff.pop())\n",
" buff.push(temp)\n", " buff.push(temp)\n",
" return buff" " return buff"
@ -252,7 +253,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,