diff --git a/linked_lists/palindrome/palindrome_challenge.ipynb b/linked_lists/palindrome/palindrome_challenge.ipynb index 2e9e854..51a5ebd 100644 --- a/linked_lists/palindrome/palindrome_challenge.ipynb +++ b/linked_lists/palindrome/palindrome_challenge.ipynb @@ -34,9 +34,15 @@ "source": [ "## Constraints\n", "\n", + "* Can we assume this is a non-circular, singly linked list?\n", + " * Yes\n", "* Is a single character or number a palindrome?\n", " * No\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", + " * Yes\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -182,21 +188,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/linked_lists/palindrome/palindrome_solution.ipynb b/linked_lists/palindrome/palindrome_solution.ipynb index a61ae82..e54c33a 100644 --- a/linked_lists/palindrome/palindrome_solution.ipynb +++ b/linked_lists/palindrome/palindrome_solution.ipynb @@ -33,9 +33,15 @@ "source": [ "## Constraints\n", "\n", + "* Can we assume this is a non-circular, singly linked list?\n", + " * Yes\n", "* Is a single character or number a palindrome?\n", " * No\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", + " * Yes\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -119,10 +125,10 @@ "\n", " # Compare the reversed list with the original list\n", " # Only need to compare the first half\n", - " iterations_to_compare_half = length // 2\n", + " iterations = length // 2\n", " curr = self.head\n", " curr_reversed = reversed_list.head\n", - " for _ in range(0, iterations_to_compare_half):\n", + " for _ in range(iterations):\n", " if curr.data != curr_reversed.data:\n", " return False\n", " curr = curr.next\n", @@ -229,21 +235,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,