mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Tweaked utopian tree algorithm discussion, cleared challenge code section.
This commit is contained in:
parent
3061020cc1
commit
d4a2300ea0
|
@ -68,7 +68,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
@ -78,15 +78,8 @@
|
|||
"# cycles = 1, print 2: i = 1: 1 * 2\n",
|
||||
"# cycles = 4, print 7: i = 1: 1 * 2, i = 2: 2 + 1, i = 3: 3 * 2, i = 4: 6 + 1\n",
|
||||
"def calc_utopian_tree_height(cycles):\n",
|
||||
" height = 1\n",
|
||||
" if cycles == 0:\n",
|
||||
" return height\n",
|
||||
" for i in xrange(1, cycles+1):\n",
|
||||
" if i % 2 == 1:\n",
|
||||
" height *= 2\n",
|
||||
" else:\n",
|
||||
" height += 1\n",
|
||||
" return height"
|
||||
" # TODO: Implement me\n",
|
||||
" pass"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
"* Return height\n",
|
||||
"\n",
|
||||
"Complexity:\n",
|
||||
"* Time: O(n), where n is the number of cycles, for each cycle we perform a calculation\n",
|
||||
"* Time: O(n)\n",
|
||||
"* Space: O(1)"
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user