{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing

# Vamsi Tallapudivamsitallapudi

🎯
Focusing
Created Sep 6, 2020
Next Greater node in Linked List
View NextGreaterNodeInLL.py
 # find next greater node and print it # eg: # Input: [2,1,5] # Output: [5,5,0] # Definition for singly-linked list. from typing import List # Definition for singly-linked list.
Last active Jun 24, 2020
 class Node: def __init__(self, data=None): self.data = data self.next = None """ Deleting a node at start. """ def delete_at_start(head):
Created Jun 24, 2020
View delete_at_given_position.py
Created Jun 24, 2020
View delete_at_end.py
Last active Jun 24, 2020
View delete_at_start.py
Created Jun 17, 2020
 class Node: def __init__(self, data=None): self.data = data self.next = None class SinglyLinkedList: def __init__(self): self.head = None
Created Jun 17, 2020
View InsertAtPosition.py
 def insert_at_pos(head, data, position): # edge case: check if pos is 0 new_node = Node(data) if position is 0: new_node.next = head head = new_node return head pos = 0 new_node = Node(data)
Created Jun 17, 2020
View InsertAtEnd.py
 def insert_at_end(head, data): new_node = Node(data) current = head while current.next: # traversing till the last node current = current.next # change the next of last node current.next = new_node return head
Created Jun 17, 2020
View InsertAtFront.py
 # insertion of new node at front of linked list def insert_at_front(head, data): # creating new node to be inserted new_node = Node(data) new_node.next = head # pointing the new node's next to head head = new_node # making the new node as head return head
Created Jun 11, 2020