mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
committed by
Donne Martin
parent
fcd4e52e91
commit
1d2b138344
@@ -33,7 +33,7 @@ class LinkedList(object):
|
|||||||
return None
|
return None
|
||||||
node = Node(data)
|
node = Node(data)
|
||||||
if self.head is None:
|
if self.head is None:
|
||||||
self.head = Node(data)
|
self.head = node
|
||||||
return node
|
return node
|
||||||
curr_node = self.head
|
curr_node = self.head
|
||||||
while curr_node.next is not None:
|
while curr_node.next is not None:
|
||||||
@@ -57,7 +57,7 @@ class LinkedList(object):
|
|||||||
if self.head is None:
|
if self.head is None:
|
||||||
return
|
return
|
||||||
if self.head.data == data:
|
if self.head.data == data:
|
||||||
self.head = None
|
self.head = self.head.next
|
||||||
return
|
return
|
||||||
prev_node = self.head
|
prev_node = self.head
|
||||||
curr_node = self.head.next
|
curr_node = self.head.next
|
||||||
|
|||||||
@@ -220,7 +220,7 @@
|
|||||||
" return None\n",
|
" return None\n",
|
||||||
" node = Node(data)\n",
|
" node = Node(data)\n",
|
||||||
" if self.head is None:\n",
|
" if self.head is None:\n",
|
||||||
" self.head = Node(data)\n",
|
" self.head = node\n",
|
||||||
" return node\n",
|
" return node\n",
|
||||||
" curr_node = self.head\n",
|
" curr_node = self.head\n",
|
||||||
" while curr_node.next is not None:\n",
|
" while curr_node.next is not None:\n",
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
" if self.head is None:\n",
|
" if self.head is None:\n",
|
||||||
" return\n",
|
" return\n",
|
||||||
" if self.head.data == data:\n",
|
" if self.head.data == data:\n",
|
||||||
" self.head = None\n",
|
" self.head = self.head.next\n",
|
||||||
" return\n",
|
" return\n",
|
||||||
" prev_node = self.head\n",
|
" prev_node = self.head\n",
|
||||||
" curr_node = self.head.next\n",
|
" curr_node = self.head.next\n",
|
||||||
@@ -485,22 +485,23 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"celltoolbar": "Edit Metadata",
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3",
|
"display_name": "Python 2",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python2"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 3
|
"version": 2
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython2",
|
||||||
"version": "3.5.0"
|
"version": "2.7.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user