Posts

LinkedList Problems for Beginners DSA || Java and DSA course || Blog 17

Image
Linked lists are fundamental data structures in computer science, offering a dynamic and flexible way to organize and manipulate data. In this blog post, we'll dive into several common linked list problems and provide clear, step-by-step solutions using Java. Whether you're preparing for technical interviews or enhancing your data structures skills, understanding how to navigate and manipulate linked lists is crucial.   We'll explore five key linked list problems and present efficient Java implementations for each:   Question 1: Problem Statement: Given a singly linked list, remove the nth node from the end of the list and return the resulting linked list. We are provided with the head of the linked list and an integer 'n,' where 1 ≤ n ≤ length of the linked list. Example 1: Input: [1,2,3,4,5], n = 2 Output: [1,2,3,5] Explanation: In the given linked list, removing the second node from the end results in the modified list [1,2,3,5]. Example 2 : Input: [1], n = 1 ...

LinkedList in DSA || Java and DSA course || Blog 16

Image
I n simple words, a collection which can contain many objects of the same type, like the ArrayList is a LinkedList. Arraylist uses dynamic array. Lets say we take an array size of 5. we gave input as 1,2,3,4,5. Now, if we gave it one more value, It creates a new arraylist of sizex2 = 5x2 = 10. it copies data from the first arraylist and then appends the new value. if something is removed between the arraylist, every value shifts one by one. Same is with the insert. From this, we can say that arraylist is better for storing values instead of manipulating it. So what is the difference between ArrayList and LinkedList? In this blog we will take a look into Singular LinkedList and code related to it. For a quick overview, contents are, What is LinkedList? Difference between arraylist and linkedlist Creating Node class Add Node at beginning Extend a node Delete first node Delete last node What is LinkedList? LinkedList is nothing but nodes connected to each other. A node is a point ...

OOPS in Java || Java and DSA course || Blog 15

Image
OOPS stands for object oriented programming system. OOPS is common in every programming language whether it is c++ or java . Modern languages are based on oops. for a quick overview , we will be learning ; constructors Polymorphism Inheritance Access Modifiers Encapsulation Abstraction what is an object and classes ? Everything in Java is associated with classes and objects, along with its attributes and methods. A Class is like an object constructor, or a "blueprint" for creating objects.  lets take a student. Here, a student is an object while attributes like name, age, section is object attributes/classes. the functions inside the classes are called members.     in the line Student student1 = new Student(); new stands for the memory allocation Student() is a special type of function called Constructors. Constructors constructors construct objects. They cannot return .Their name should be same in the class . It calls only one time. there are 3 types of constructors: N...