From 4c45be5a9ebd33ebeffca0b998a3e721e58e4fa8 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sun, 12 Jun 2016 23:16:06 -0400 Subject: [PATCH] Exit out of loop once key is found/removed from hash map --- arrays_strings/hash_map/hash_map_challenge.ipynb | 10 +++++----- arrays_strings/hash_map/hash_map_solution.ipynb | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/arrays_strings/hash_map/hash_map_challenge.ipynb b/arrays_strings/hash_map/hash_map_challenge.ipynb index 1f7c042..47de5a4 100644 --- a/arrays_strings/hash_map/hash_map_challenge.ipynb +++ b/arrays_strings/hash_map/hash_map_challenge.ipynb @@ -196,21 +196,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.5.0" } }, "nbformat": 4, diff --git a/arrays_strings/hash_map/hash_map_solution.ipynb b/arrays_strings/hash_map/hash_map_solution.ipynb index b98dc15..363e080 100644 --- a/arrays_strings/hash_map/hash_map_solution.ipynb +++ b/arrays_strings/hash_map/hash_map_solution.ipynb @@ -149,7 +149,8 @@ " hash_index = self.hash_function(key)\n", " for i, item in enumerate(self.table[hash_index]):\n", " if item.key == key:\n", - " del self.table[hash_index][i]" + " del self.table[hash_index][i]\n", + " return" ] }, { @@ -253,21 +254,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.5.0" } }, "nbformat": 4,