class Node:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self, value):
node = Node(value)
self.head = node
self.tail = node
self.length = 1
def __str__(self):
curr = self.head
s = ""
while curr is not None:
if len(s) == 0:
s = str(curr.value)
else:
s = s+"->"+str(curr.value)
curr = curr.next
return s
def append(self, value):
node = Node(value)
self.tail.next = node
self.tail = node
self.length += 1
def addAt(self, value, index):
n = Node(value)
if index > self.length:
raise Exception("Index out of bounds")
if index == 1:
temp = self.head
self.head = n
self.head.next = temp
else:
i = 1
index = index - 1
prevN = self.head
nextN = self.head.next
while i<index:
i += 1
prevN = prevN.next
nextN = nextN.next
n.next = nextN
prevN.next = n
self.length += 1
def search(self, value):
curr = self.head
while curr is not None:
if curr.value == value:
print("Search value ", value,"exists in LL")
return True
curr = curr.next
print("Search value " , value," does not exists in LL")
return False
def getAt(self, index):
if index > self.length:
raise Exception("Index out of bounds")
return false
if index == 1:
print(head.value)
return head.value
else:
i=1
index = index
curr = self.head
while i<index and curr is not None:
i += 1
curr = curr.next
print("Element at index ", index, " is ", curr.value)
return curr.value
def setAt(self, index, value):
if index > self.length:
raise Exception("Index out of bounds")
return false
if index == 1:
head.value = value;
return
else:
i=1
index = index
curr = self.head
while i<index and curr is not None:
i += 1
curr = curr.next
curr.value = value;
return
def pop_first(self):
if self.length == 0:
print("LL is empty")
return
self.head = self.head.next
self.length -= 1
def pop(self, index):
if index > self.length:
raise Exception("Index out of bounds")
return false
if self.length == 0:
print("LL is empty")
return
elif self.length == 1:
self.head = None
self.length = 0
else:
i=2
curr = self.head
while i<index:
curr = curr.next
i += 1
curr.next = None;
self.length -= 1
l = LinkedList(10)
l.append(20)
l.append(30)
l.append(40)
print(l)
l.addAt(50, 4)
l.search(50)
l.search(110)
print(l)
l.getAt(3)
l.setAt(2, 99)
print(l)
l.pop_first()
l.pop(4)
print(l)
Benefits of TheCodeground Online IDE
Multi-Language Support
TheCodeground Online IDE supports C++, Java, Node.js, Python, and more, making it an incredibly versatile tool for diverse coding needs. This extensive language support allows developers to work on different projects within a single platform.
Real-Time Collaboration
Our real-time collaboration feature enables multiple developers to work on the same project simultaneously, enhancing teamwork and productivity. This feature is particularly beneficial for remote teams and pair programming sessions.
User-Friendly Interface
Designed with a clean and intuitive interface, TheCodeground Online IDE simplifies coding and debugging processes, making it accessible for users of all skill levels. The ease of use and clear navigation ensure a smooth coding experience.
Instant Code Execution
Experience fast and efficient code execution with immediate feedback in the integrated terminal. This feature helps streamline the development process, allowing developers to quickly test and debug their code.
Free to Use
Enjoy the full range of features at no cost. TheCodeground Online IDE is completely free, providing a valuable resource for developers without any subscription fees. This makes it an ideal choice for students, hobbyists, and professionals alike.
Cloud-Based Platform
As a cloud-based IDE, TheCodeground allows you to access your projects from anywhere, at any time. This flexibility ensures that you can continue coding without being tied to a specific device or location.
Customizable Environment
Tailor the IDE to your preferences with customizable themes, layouts, and extensions. This personalization ensures a comfortable and productive coding environment.
Why Choose TheCodeground Over Other Online IDEs?
TheCodeground Online IDE stands out from the competition with its comprehensive feature set, ease of use, and cost-effectiveness. Unlike many other online IDEs that require subscriptions or offer limited free plans, TheCodeground provides all its features for free. Our multi-language support, real-time collaboration, and advanced debugging tools ensure that you have everything you need for effective development. Additionally, our user-friendly interface and customizable environment make coding a pleasant experience, regardless of your expertise level. Choose TheCodeground Online IDE for a seamless, efficient, and enjoyable coding experience.