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",
" * 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,

View File

@ -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,