🚀Day 98/100 #100DaysOfLeetCode 🧩Problem: Linked List Cycle✅ 👩💻Language: Java 🧠Approach: Used the Floyd’s Cycle Detection Algorithm (Tortoise and Hare Method). Two pointers move through the list — slow moves one step at a time, while fast moves two steps. If there’s a cycle, both pointers will eventually meet; otherwise, the list ends without intersection. 💡Key Takeaways: 🔹Efficiently detects a cycle using O(1) space. 🔹Demonstrates a classic use of the two-pointer technique. 🔹A must-know algorithm for linked list manipulation and interview prep. ⚙️Performance: ⏱️Runtime: 0 ms (Beats 100.00%) 💾Memory: 44.16 MB (Beats 96.16%) #100DaysOfLeetCode #Java #ProblemSolving #LinkedList #DataStructures #LeetCode #CodingJourney #CodingChallenge #FloydAlgorithm
Solved Linked List Cycle problem using Floyd's Algorithm in Java
More Relevant Posts
-
🚀Day 95/100 #100DaysOfLeetCode 🔍Problem: Length of Last Word✅ 💻Language: Java 🧠Approach: 1️⃣ First, trim the string to remove trailing and leading spaces. 2️⃣ Initialize a counter to 0. 3️⃣ Traverse the string from the end. 4️⃣ Count characters until the first space is encountered. 5️⃣ Return the count as the length of the last word. 💡Key Takeaways: 🔹Trimming the input ensures no trailing spaces interfere. 🔹Backward traversal avoids splitting the entire string. 🔹Simple yet efficient one-pass solution. ⚡Performance: ⏱️Runtime: 0 ms (Beats 100.00%) 💾Memory: 41.58 MB (Beats 91.52%) #100DaysOfLeetCode #Java #CodingJourney #ProblemSolving #LeetCode #CodingChallenge
To view or add a comment, sign in
-
-
Collection vs. Collections... do you know the difference? One is an interface (the blueprint), and the other is a utility class (the toolbox). This is just one of the concepts I clarify in my latest Medium article. I wrote "A Detailed Guide to the Java Collection Framework" to help developers move beyond fixed-size arrays and master dynamic data structures. In this article, I cover: 🔹 The Hierarchy (List, Set, Queue) 🔹 The Map Interface 🔹 When to use ArrayList vs. LinkedList 🔹 Thread safety tips If you are looking to brush up on your Java basics or prepare for an interview, give it a read! [https://lnkd.in/gwe_J4Wf] #Java #Tech #CodingTips #SoftwareEngineering #LearningEveryday
To view or add a comment, sign in
-
-
🎯 Day 62 of #100DaysOfLeetCode Today I solved the “Merge Two Sorted Lists” problem using Java This problem is a great exercise in understanding how to work with Linked Lists and pointer manipulation. The goal is to merge two sorted linked lists into one sorted list — without using extra space for another list. Key Concepts Practiced: Linked List traversal Dummy node technique Efficient merging using pointers Handling null edge cases Approach Summary: Create a dummy node to simplify edge cases. Use two pointers to traverse both lists. Compare values and link nodes in sorted order. Attach any remaining nodes at the end. #100DaysOfCode #LeetCode #Java #CodingChallenge #DataStructures #LinkedList #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
💡 Today I solved the famous “Two Sum” problem in Java — one of the most popular questions in coding interviews! The challenge: Given an array of integers and a target value, find two numbers that add up to the target. 🔑 Approach: Instead of using nested loops (which take O(n²) time), I used a HashMap to store previously visited elements and check if target - current exists in the map. This reduced the time complexity to O(n) ✅ 💻 Key Learnings: - How to use HashMap effectively for quick lookups. - The importance of choosing the right data structure. - How small optimizations can make a big performance difference. - Problem-solving with Maps not only improves efficiency but also helps build the right mindset for real-world backend challenges 🚀. #DSA #ProblemSolving #LeetCode #Java #CodingJourney #BackendDevelopment #CleanCode
To view or add a comment, sign in
-
🚀Day 94/100 #100DaysOfLeetCode 🧩Problem: Reverse Words in a String III✅ 💻Language: Java 🔍Approach: 🔹Split the given string by spaces to separate each word. 🔹For every word, reverse it using a StringBuilder. 🔹Append each reversed word back to the result string, adding spaces between them. 🔹Finally, return the complete reversed word string. 🧠Key Takeaways: 🔹Practiced efficient string manipulation using StringBuilder. 🔹Learned how splitting and reversing operations can be optimized for clarity. 🔹Strengthened understanding of text processing in Java. ⚡Performance: ⏱️Runtime: 4 ms (Beats 86.86%) 💾Memory: 45.49 MB (Beats 47.42%) #100DaysOfLeetCode #Java #CodingJourney #LeetCode #CodingChallenge #ProblemSolving
To view or add a comment, sign in
-
-
💻✨ Just revisited one of my favorite Java exercises—building a diamond pattern using nested loops! It’s a simple yet elegant way to practice control flow and logic structuring. For input 3, the output looks like this: * *** ***** *** * This kind of pattern generation sharpens your understanding of loop nesting and space management in console output. If you're learning Java or prepping for interviews, try writing this from scratch—no copy-paste! 😄 🔍 Curious to see how others would optimize or extend this? Drop your version or ideas in the comments! #Java #CodingPractice #PatternPrinting #DeveloperJourney #100DaysOfCode #LinkedInLearning
To view or add a comment, sign in
-
-
Today I worked on the problem "Convert Sorted List to Binary Search Tree" in Java — a perfect blend of Linked List and Tree logic! 🌳 🔍 Key Concepts Covered: Finding the middle element of a Linked List using the slow & fast pointer approach Recursively constructing a height-balanced BST Strengthening understanding of Divide and Conquer strategies This problem really sharpened my thinking around recursive structures and pointer management — small yet powerful steps toward writing more efficient and elegant Java code. 💻✨ 💬 What’s your favorite data structure to work with — Linked Lists or Trees? #LeetCode #Java #DataStructures #Algorithms #CodingJourney #LearningEveryday #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 26 of 100 Days of LeetCode 📘 Problem: Search a 2D Matrix 💻 Language: Java ✅ Status: Accepted — Runtime: ⚡ 0 ms (Beats 100%) Today’s problem focused on searching efficiently within a 2D matrix — a great exercise for understanding nested loops, traversal logic, and time optimization. While this version used a simple brute-force approach, it served as a good refresher on matrix iteration patterns before moving on to more optimized binary search techniques in 2D grids. ✨ Key Learnings: Matrix traversal can be intuitive when visualized 🔢 Always consider both brute-force and optimized approaches — understanding both is key to depth of knowledge Writing clean, readable code matters as much as optimizing it Each problem solved is another small brick in the foundation of strong problem-solving skills 💪 #Day26 #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney #SoftwareDevelopment #Matrix #KeepLearning #CodeEveryday
To view or add a comment, sign in
-
-
Day 16 of my #JavaWithDSAChallenge Today I solved LeetCode Problem 28: Find the Index of the First Occurrence in a String - a simple yet very commonly asked coding interview question. Problem Summary Given two strings haystack and needle, the goal is to return the index of the first occurrence of needle inside haystack. If the substring doesn’t exist, we return -1. This problem helps strengthen: String manipulation Searching techniques Built-in Java utility understanding My Approach Java provides a very handy method: haystack.indexOf(needle) This directly returns the first matched index or -1 if no match exists. So the solution becomes clean, efficient, and readable - perfect for interviews where clarity matters as much as correctness. Code Implementation (Java) class Solution { public int strStr(String haystack, String needle) { // Directly using Java's built-in function return haystack.indexOf(needle); } } Key Takeaways Not all problems need complex algorithms — sometimes, built-ins are optimized and enough. #Day16 #JavaWithDSAChallenge #leetcode #codingchallenge #100DaysOfCode #Java #DSA #SoftwareEngineering #ProblemSolving #WomenInTech #TechJourney #LearningEveryday #InterviewPreparation
To view or add a comment, sign in
-
-
🚀 Day 5 — The “Polymorphism Trap” That Even 5+ Year Devs Fall Into 😵💫 Everyone thinks they know Polymorphism… Until Overloading and Overriding collide inside the same class 🔥 class Parent { void calc(Number n) { System.out.println("Parent Number"); } void calc(Integer i) { System.out.println("Parent Integer"); } } class Child extends Parent { @Override void calc(Number n) { System.out.println("Child Number"); } } public class PolymorphPuzzle { public static void main(String[] args) { Parent p = new Child(); p.calc(null); } } 💭 Question: What will be the output? 1️⃣ Parent Number 2️⃣ Parent Integer 3️⃣ Child Number 4️⃣ Compile-time Error 💬 Drop your answer in the comments 👇 90% developers get this wrong — can you get it right without running the code? 😎 Let’s see who’s the real Java champ 🧠🔥 #Java #Polymorphism #CodingChallenge #SpringBoot #InterviewQuestion #Day5Challenge #JavaDeveloper #LearnJava #OOPsConcepts
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