From 8cc41e23afa4e7a458acfa5e2cf9c45cc905424e Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sun, 12 Jun 2016 23:25:49 -0400 Subject: [PATCH] Polish remove duplicates challenge and solution Update constraints and algorithm discussion. --- .../remove_duplicates_challenge.ipynb | 8 ++++--- .../remove_duplicates_solution.ipynb | 21 ++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/linked_lists/remove_duplicates/remove_duplicates_challenge.ipynb b/linked_lists/remove_duplicates/remove_duplicates_challenge.ipynb index 496ba8e..92a728f 100644 --- a/linked_lists/remove_duplicates/remove_duplicates_challenge.ipynb +++ b/linked_lists/remove_duplicates/remove_duplicates_challenge.ipynb @@ -38,9 +38,11 @@ " * Singly\n", "* Can you insert None values in the list?\n", " * No\n", - "* Can you use additional data structures?\n", - " * Implement both solutions\n", "* Can we assume we already have a linked list class that can be used for this problem?\n", + " * Yes\n", + "* Can we use additional data structures?\n", + " * Implement both solutions\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -193,7 +195,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4, diff --git a/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb b/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb index 74e5a89..ef1b974 100644 --- a/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb +++ b/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb @@ -38,9 +38,11 @@ " * Singly\n", "* Can you insert None values in the list?\n", " * No\n", - "* Can you use additional data structures?\n", - " * Implement both solutions\n", "* Can we assume we already have a linked list class that can be used for this problem?\n", + " * Yes\n", + "* Can we use additional data structures?\n", + " * Implement both solutions\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -62,6 +64,8 @@ "source": [ "## Algorithm: Hash Map Lookup\n", "\n", + "Loop through each node\n", + "\n", "* For each node\n", " * If the node's value is in the hash map\n", " * Delete the node\n", @@ -70,10 +74,7 @@ "\n", "Complexity:\n", "* Time: O(n)\n", - "* Space: O(n)\n", - "\n", - "Note:\n", - "* Deletion requires two pointers, one to the previous node and one to the current node" + "* Space: O(n)" ] }, { @@ -84,17 +85,13 @@ "\n", "* For each node\n", " * Compare node with every other node\n", - " * If the node's value is in the hash map\n", - " * Delete the node\n", - " * Else\n", - " * Add node's value to the hash map\n", + " * Delete nodes that match current node\n", "\n", "Complexity:\n", "* Time: O(n^2)\n", "* Space: O(1)\n", "\n", "Note:\n", - "* Deletion requires two pointers, one to the previous node and one to the current node\n", "* We'll need to use a 'runner' to check every other node and compare it to the current node" ] }, @@ -258,7 +255,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4,