🚀 Daily DSA Practice – Day 16 | Linked List Operations (Java) As part of my continued Data Structures & Algorithms preparation, today I practiced essential linked list manipulation problems, focusing on node comparison, deletion, and clean list restructuring using Java. 📌 Problems Solved (LeetCode): • 21. Merge Two Sorted Lists – Merging two lists using a dummy node for clean pointer management • 83. Remove Duplicates from Sorted List – Eliminating consecutive duplicates in a sorted list • 203. Remove Linked List Elements – Removing nodes with a target value using dummy head technique 🎯 Key Learnings: ✔ Improved confidence with dummy nodes to simplify edge cases ✔ Strengthened understanding of pointer traversal and node deletion ✔ Handled head-node modifications safely and cleanly ✔ Implemented O(n) time and O(1) space optimized Java solutions These problems further solidified my grasp of linked list fundamentals, which are commonly tested in technical interviews. #DSA #LeetCode #Java #LinkedList #ProblemSolving #BackendDeveloper #SoftwareEngineer #InterviewPreparation
Linked List Operations in Java | LeetCode Solutions
More Relevant Posts
-
🚀 Daily DSA Practice – Day 18 | Two-Pointer Techniques in Linked Lists (Java) As part of my ongoing Data Structures & Algorithms preparation, today I focused on two-pointer–based linked list problems, strengthening my ability to manage node alignment, traversal synchronization, and list restructuring using Java. 📌 Problems Solved (LeetCode): • 160. Intersection of Two Linked Lists – Identifying the intersection point using pointer switching technique • 19. Remove Nth Node From End of List – Single-pass solution using slow and fast pointers • 61. Rotate List – Rotating a linked list by k positions through length calculation and pointer reconnection 🎯 Key Learnings: ✔ Applied pointer synchronization to solve intersection problems efficiently ✔ Strengthened one-pass linked list traversal techniques ✔ Improved handling of cyclic connections and boundary conditions ✔ Implemented O(n) time and O(1) space optimized Java solutions These problems further enhanced my understanding of linked list mechanics and prepared me for real-world interview scenarios involving pointer-based logic. #DSA #LeetCode #Java #LinkedList #TwoPointers #ProblemSolving #BackendDeveloper #SoftwareEngineer #InterviewPreparation
To view or add a comment, sign in
-
🚀 Daily DSA Practice – Day 20 | Advanced Linked List Manipulation (Java) As part of my ongoing Data Structures & Algorithms preparation, today I focused on advanced linked list problems involving complex pointer relationships, duplicate handling, and node swapping, all implemented using Java. 📌 Problems Solved (LeetCode): • 138. Copy List with Random Pointer – Created a deep copy using efficient node mapping to preserve random pointers • 82. Remove Duplicates from Sorted List II – Removed all nodes with duplicate values using careful pointer traversal • 24. Swap Nodes in Pairs – Swapped adjacent nodes using in-place pointer manipulation 🎯 Key Learnings: ✔ Improved handling of complex node relationships and deep copy logic ✔ Strengthened understanding of duplicate elimination in sorted lists ✔ Mastered safe node swapping without modifying node values ✔ Implemented O(n) time and O(1) / O(n) space optimized Java solutions These problems pushed my understanding of linked list internals and enhanced my confidence in solving medium-level interview problems involving non-trivial pointer logic. #DSA #LeetCode #Java #LinkedList #ProblemSolving #BackendDeveloper #SoftwareEngineer #InterviewPreparation
To view or add a comment, sign in
-
🚀 From Singly -> Doubly Linked List (Built From Scratch in Java) Last time, I shared my custom Singly Linked List. This time, I leveled up 👇 👉 Generic Doubly Linked List in Java, fully implemented from scratch. Why Doubly Linked List? Because real understanding comes when you add complexity, not avoid it. 💡 What I implemented: Generic design (<T>) Forward and backward traversal O(1) insert/delete at both ends Index-based operations contains, indexOf, lastIndexOf Reverse display Clean edge-case handling 📈 What changed in my thinking: Every extra pointer changes everything Small design mistakes break big systems Data Structures are not “theory” , they are engineering This is exactly why I prefer building over memorizing. 📌 GitHub link in comments (Feedback from seniors & developers is welcome 🙌) #Java #DataStructures #DSA #LinkedList #ComputerScience #JavaDeveloper #BuildInPublic #LearningJourney #Consistency
To view or add a comment, sign in
-
#Day17 💭 Today I came across an interview question asked in one of the product-based companies “What are the different types of thread pools in Java and how do you decide which one to use?” Before even talking about types, the first thing I understood was: 👉 What exactly is a Thread Pool? A thread pool is simply a collection of reusable threads that are created in advance and managed by Java. Instead of creating a new thread for every task (which is costly and slow), we: • Submit tasks to a pool • Available threads pick them up • After finishing, threads are reused for the next task This makes the application faster, more stable, and resource-efficient. So here’s what I understood in a simple way 👇 🔹 Fixed Thread Pool Used when we want a fixed number of threads and don’t want the system to create more. 📌 Example: Database or payment-related tasks where resource control is important. 🔹 Cached Thread Pool Creates threads when needed and reuses them. 📌 Example: Handling many short tasks or sudden traffic spikes. ⚠️ Needs careful usage for long-running tasks. 🔹 Single Thread Executor Only one thread executes tasks one by one. 📌 Example: Logging or tasks where order matters. 🔹 Scheduled Thread Pool Used for tasks that need to run after some delay or repeatedly. 📌 Example: Cleanup jobs, retry mechanisms. 🔹 Work Stealing Pool Helps in better parallel processing by sharing work between threads. 📌 Example: CPU-intensive tasks like file processing. 🧠 What I learned from this question It’s not about remembering definitions. It’s about understanding: • Nature of the task • Resource usage • Order vs parallel execution That decides the thread pool. 📌 Sharing this as part of my learning journey. Still learning, step by step. #Java #Multithreading #InterviewPreparation #BackendDevelopment #LearningInPublic #JavaDeveloper
To view or add a comment, sign in
-
🚀 Day 32 Out of #365DaysOfCode -LeetCode ✅ LeetCode Problem Solved: Delete the Middle Node of a Linked List I solved the Delete the Middle Node problem on LeetCode by analyzing the length of the linked list and removing the middle element in a clean and structured way. 🔹 Approach Used: First traversed the linked list to calculate its total size Identified the middle index using size / 2 Traversed again to reach the node just before the middle Adjusted pointers to delete the middle node safely 🔹 Key Concepts Practiced: Linked List traversal Pointer manipulation Edge case handling (empty list or single node) 🔹 Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) 📌 This problem helped strengthen my understanding of linked list operations and pointer-based problem solving in Java. #LeetCode #Java #LinkedList #DSA #ProblemSolving #CodingPractice #InterviewPreparation #LearningJourney Github link: https://lnkd.in/gGUy_MKZ
To view or add a comment, sign in
-
-
🚀 Solved: Longest Common Prefix Problem (Java) Today, I worked on the Longest Common Prefix problem — a classic string manipulation question frequently asked in coding interviews. 🔹 Problem Statement Given an array of strings, find the longest common prefix shared among all strings. If no common prefix exists, return an empty string. 🔹 Approach Used Assume the first string as the initial prefix Compare it with the remaining strings Gradually reduce the prefix until all strings start with it If the prefix becomes empty, return "" 🔹 Why this approach? ✔ Simple and intuitive ✔ Efficient with O(n × m) time complexity ✔ Uses constant extra space ✔ Easy to explain in interviews 🔹 Sample Input ["flower", "flow", "flight"] 🔹 Output "fl" 📌 Key Learning Sometimes the most effective solution is not complex — starting with a clear assumption and refining it step by step can solve the problem efficiently. 💻 Language Used: Java 🧠 Concepts: Strings, loops, prefix matching #Java #DSA #CodingPractice #ProblemSolving #LeetCode #InterviewPreparation #LearningJourney
To view or add a comment, sign in
-
-
🚀 Solved: Remove Nth Node From End of a Linked List (Java) Today I revisited a classic Linked List problem and solved it using the Two Pointer Technique 🧠✨ 💡 Problem Statement Remove the N-th node from the end of a singly linked list efficiently. ✅ Approach Used 🔹 Fast Pointer moves n steps ahead 🔹 Slow Pointer starts from the head 🔹 Both pointers move together until the fast pointer reaches the end 🔹 The slow pointer then points to the node just before the one to be removed 🔹 Adjusting the link removes the target node safely ⚡ Why this approach works well ✔ Solves the problem in one pass ✔ No extra data structures required ✔ Time Complexity: O(n) ✔ Space Complexity: O(1) 📌 Key Learning 👉 Two-pointer techniques are extremely effective for optimizing linked list problems and avoiding unnecessary traversals. 📈 Consistently practicing such problems improves logical thinking and confidence in DSA. 💬 Happy to discuss or learn alternative approaches! 🔗 #Java #LinkedList #TwoPointers #DSA #ProblemSolving #CodingJourney #LeetCode #SoftwareEngineer 🚀
To view or add a comment, sign in
-
-
Here are some more questions for you guys to check out 😊: 1.How does a Set ensure uniqueness, and what internal checks are performed to detect duplicates? 2.Which sorting algorithm is used internally by Collections.sort() in Java, and why was it chosen? 3.How do you handle circular dependencies in a Spring-based project? What approaches have you used in real scenarios? 4.If the same Spring event is published multiple times with different outcomes, how does Spring differentiate and route these events to the appropriate listeners? 5.How would you design and implement a cache that refreshes itself at fixed intervals without using cron jobs? If these questions helped you, hit like 👍, share 🔁, and tag a fellow developer who might benefit from them. #JavaInterview #SpringInterview #InterviewQuestions #TechInterviews #CodingInterviews
To view or add a comment, sign in
-
🚀 Solved: Add Two Numbers (Linked List) in Java ☕ Today I worked on the classic Linked List problem where two numbers are represented in reverse order, and the task is to return their sum as a linked list. 💡 Key Ideas Used: 🔹 Traverse both linked lists simultaneously 🔹 Handle different lengths using default 0 🔹 Maintain a carry for sums ≥ 10 🔹 Use a dummy head node to simplify list construction 🧠 Why this approach works: ✔ Clean and readable logic ✔ Handles edge cases like carry at the end ✔ Efficient with O(max(n, m)) time complexity 📌 Core Logic: Add node values + carry Store sum % 10 as the current digit Update carry = sum / 10 Move pointers safely This problem really helped me strengthen my understanding of linked lists, pointer movement, and edge-case handling 🔗 💬 Always open to feedback and discussions! #Java #DataStructures #LinkedList #DSA #ProblemSolving #LeetCode #CodingJourney 💻✨
To view or add a comment, sign in
-
-
#Day26 First Non-Repeating Character in a String : This is a classic Java interview problem that looks simple, but actually checks: • how you think about time & space complexity • whether you choose the right data structure • how you preserve original order 🧠 Approach Used Instead of Java 8 streams or maps, I used a frequency array to achieve the most optimized solution. 📌 Why this works well • Two linear passes → O(n) • Fixed-size array → constant space • No extra objects or streams • Maintains original order of characters • Scales well for large inputs ⚡️Why not streams? Streams improve readability, but for performance-critical problems, array-based counting is the fastest and most memory-efficient approach. I’m documenting my Java & DSA interview prep with clean, optimized solutions. More such problems coming soon 🚀 #Java #DSA #CodingInterview #SoftwareEngineer #Backend #ProblemSolving #LearningInPublic #Consistency
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development