mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 00:48:03 +00:00
Polish merge sort challenge and solution
Update constraints and code.
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
"* Is a naiive solution sufficient?\n",
|
"* Is a naiive solution sufficient?\n",
|
||||||
|
" * Yes\n",
|
||||||
|
"* Are duplicates allowed?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -163,7 +165,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,
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
"* Is a naiive solution sufficient?\n",
|
"* Is a naiive solution sufficient?\n",
|
||||||
|
" * Yes\n",
|
||||||
|
"* Are duplicates allowed?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -118,7 +120,7 @@
|
|||||||
" if data is None or len(data) < 2:\n",
|
" if data is None or len(data) < 2:\n",
|
||||||
" return data\n",
|
" return data\n",
|
||||||
" mid = len(data) // 2\n",
|
" mid = len(data) // 2\n",
|
||||||
" left = data[0:mid]\n",
|
" left = data[:mid]\n",
|
||||||
" right = data[mid:]\n",
|
" right = data[mid:]\n",
|
||||||
" left = merge_sort(left)\n",
|
" left = merge_sort(left)\n",
|
||||||
" right = merge_sort(right)\n",
|
" right = merge_sort(right)\n",
|
||||||
@@ -227,7 +229,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,
|
||||||
|
|||||||
Reference in New Issue
Block a user