Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: iamvaibhavsingh09/Data-Structures-Algorithms-in-Python-CodingNinjas
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: ayushraj29017/Data-Structures-Algorithms-in-Python-CodingNinjas
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Oct 5, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4666715 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b232860 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ecc991a View commit details
Showing with 36 additions and 77 deletions.
  1. +36 −77 10. Linked List-1/2. Linked List Input & Print.ipynb
113 changes: 36 additions & 77 deletions 10. Linked List-1/2. Linked List Input & Print.ipynb
Original file line number Diff line number Diff line change
@@ -1,77 +1,36 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 2 3 4 5 -1\n",
"1->2->3->4->5->None\n"
]
}
],
"source": [
"class Node:\n",
" def __init__(self,data):\n",
" self.data = data\n",
" self.next = None\n",
" \n",
"def printLL(head):\n",
" \n",
" while head is not None:\n",
" print(str(head.data) + \"->\",end=\"\")\n",
" head = head.next\n",
" print(\"None\")\n",
" return\n",
" \n",
"def takeInput():\n",
" \n",
" inputList = [int(ele) for ele in input().split()]\n",
" head = None\n",
" for currData in inputList:\n",
" if currData == -1:\n",
" break\n",
" \n",
" newNode = Node(currData)\n",
" if head is None:\n",
" head = newNode\n",
" \n",
" else:\n",
" curr = head\n",
" while curr.next is not None:\n",
" curr = curr.next\n",
" curr.next = newNode\n",
" \n",
" return head\n",
"\n",
"head = takeInput()\n",
"printLL(head)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
class Node:
def __init__(self,data):
self.data = data
self.next = None

def printLL(head):

while head is not None:
print(str(head.data) + "->",end="")
head = head.next
print("None")
return

def takeInput():

inputList = [int(ele) for ele in input().split()]
head = None
for currData in inputList:
if currData == -1:
break

newNode = Node(currData)
if head is None:
head = newNode

else:
curr = head
while curr.next!=None:
curr = curr.next
curr.next = newNode

return head

head = takeInput()
print(head)
printLL(head)