mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
parent
cf337334a5
commit
0bf56834c0
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user