🚀 [Day 16/30] Coding Challenge with @Educative.io 💻 💡 Problem: Linked List Cycle Today’s challenge was about detecting whether a linked list contains a cycle — a classic problem that tests pointer logic. I used Floyd’s Cycle Detection Algorithm (Tortoise & Hare): 1️⃣ Move one pointer one step at a time 2️⃣ Move another pointer two steps at a time 3️⃣ If they ever meet → a cycle exists 4️⃣ If the fast pointer reaches null → no cycle This approach runs in O(n) time and O(1) space — clean and optimal. ✨ Small win: Realizing how pointer speed differences can expose cycles without extra memory is always satisfying. 🔍 Key Learnings: Cycle detection doesn’t need extra space Pointer manipulation is key in linked list problems Floyd’s algorithm is a must-know for interviews #30DaysOfCode #Day15 #CodingChallenge #Educative #DSA #LinkedList #TwoPointers #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
Detecting Linked List Cycles with Floyd's Algorithm
More Relevant Posts
-
🚀 [Day 18/30] Coding Challenge with @Educative.io 💻 💡 Problem: Invert Binary Tree Today’s challenge was a classic tree problem — inverting a binary tree by swapping the left and right children of every node. The logic was simple yet powerful: 👉 Traverse the tree and swap left ↔ right at each node. I approached it using recursion: 1️⃣ Swap the left and right child 2️⃣ Recursively apply the same logic to both subtrees This can also be solved iteratively using BFS or DFS, but recursion keeps the solution very clean and readable. ✨ Small win: Problems like this remind me how elegant tree recursion can be — minimal code, clear intent. 🔍 Key Learnings: Tree transformations are often recursive by nature Preorder traversal works well for structural changes Simple problems still reinforce core fundamentals #30DaysOfCode #Day18 #CodingChallenge #Educative #DSA #BinaryTree #Recursion #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
To view or add a comment, sign in
-
🚀 [Day 17/30] Coding Challenge with @Educative.io 💻 💡 Problem: Split Array Largest Sum Today’s challenge was an interesting mix of binary search + greedy validation. The goal was to split an array into m subarrays such that the largest subarray sum is minimized. The key insight: 👉 If we fix a maximum allowed subarray sum, we can greedily check whether the array can be split into at most m parts. My approach: 1️⃣ Set the search space between max(nums) and sum(nums) 2️⃣ Used binary search to guess the optimal maximum sum 3️⃣ For each guess, greedily counted how many subarrays were needed 4️⃣ Adjusted the search range based on feasibility This turned a complex optimization problem into a clean decision problem.| ✨ Small win: Realizing how “minimize the maximum” problems often map directly to binary search was a big confidence booster. 🔍 Key Learnings: Binary search isn’t just for sorted arrays Greedy checks pair perfectly with binary search Optimization problems often hide feasibility checks #30DaysOfCode #Day17 #CodingChallenge #Educative #DSA #BinarySearch #Greedy #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
To view or add a comment, sign in
-
🚀 Day 4 / 150 – LeetCode Top Interview Coding Challenge 🧑💻✨ Problem: LeetCode 80 – Remove Duplicates from Sorted Array II This challenge focuses on modifying a sorted array in-place so that each element appears no more than twice, while returning the new valid length. Example: Input: nums = [1,1,1,2,2,3] Output: 5 Resulting array: [1,1,2,2,3,_] The solution uses an efficient two-pointer technique to ensure only allowed duplicates are retained without using extra space. Time Complexity: O(n) Space Complexity: O(1) Continuing to strengthen problem-solving skills through consistent practice and structured challenges. #LeetCode #CodingPractice #DataStructures #Algorithms #CPlusPlus #SoftwareEngineering #InterviewPreparation
To view or add a comment, sign in
-
-
Day 8 of 30-day Coding Sprint Today’s focus was on a classic problem that teaches you why linear time isn't always good enough when dealing with exponents. Today's progress on LeetCode: 50. Pow(x, n) The Simple Recursive Approach: Multiplying x by itself n times. - Complexity: O(n) time. - The Issue: For large values of n, this hits the stack limit or simply takes too long. The Optimal Strategy: Binary Exponentiation (Divide & Conquer) - The Logic: Use the property (x^n) = (x^n/2)^2. By halving n at each recursive step, we drastically reduce the number of multiplications. The Result: O(log n) time. This turns a billion operations into roughly 30. #30DaysOfCode #DSASprint #LeetCode #JavaScript #Recursion #Math #Consistency
To view or add a comment, sign in
-
-
Leetcode problem No : 75 Just implemented a simple Selection-style Sorting in Java! For each position in the array, I find the smallest element and swap it into place. This beginner-friendly approach helps understand how sorting algorithms work step by step. Time complexity is O(n2)O(n^2)O(n2) and space complexity is O(1)O(1)O(1) — easy to grasp for starters. Perfect exercise for anyone preparing for LeetCode, coding interviews, or learning algorithms! #Java #Coding #Programming #Algorithms #DataStructures #LeetCode #Sorting #Developer #TechLearning #CareerGrowth
To view or add a comment, sign in
-
-
🚀 Beginner Guide to Coding Confused about how to start coding? This simple visual roadmap makes it clear 👇 🔹 Understand what coding really is 🔹 Choose your first language (Python / HTML-CSS / JavaScript) 🔹 Learn core concepts like variables, loops & logic 🔹 Build small projects (calculator, to-do app, portfolio) 🔹 Practice daily & grow with Git, APIs and frameworks 🔹 Finally, create something BIG 💡 💻 Coding is not about being perfect — it’s about being consistent. Start small. Practice daily. Build projects. Repeat. If you’re a student / beginner / career switcher, this roadmap is for you 🙌 #Coding #Programming #Beginners #LearnToCode #Python #JavaScript #WebDevelopment #ComputerScience #Students #TechJourney
To view or add a comment, sign in
-
-
𝐄𝐱𝐜𝐢𝐭𝐞𝐝 𝐭𝐨 𝐬𝐡𝐚𝐫𝐞 𝐦𝐲 𝐟𝐢𝐫𝐬𝐭 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐭𝐮𝐭𝐨𝐫𝐢𝐚𝐥! 🎉 𝗧𝗼𝗽𝗶𝗰: 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐄𝐱𝐞𝐜𝐮𝐭𝐢𝐨𝐧 𝐂𝐨𝐧𝐭𝐞𝐱𝐭—𝐓𝐡𝐞 𝐅𝐨𝐮𝐧𝐝𝐚𝐭𝐢𝐨𝐧 𝐨𝐟 𝐉𝐒 In this comprehensive tutorial, I've covered: - What is Execution Context and why does it matter? - Creation & Execution phases explained - Call stack visualization - Common mistakes to avoid Perfect for beginners and those preparing for interviews. 🔗 𝐖𝐚𝐭𝐜𝐡 𝐡𝐞𝐫𝐞: https://lnkd.in/gk8gMjxg Feedback and suggestions are always welcome. #JavaScript #WebDevelopment #Programming #Tutorial #LearnToCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 15 Must-Know Patterns for Cracking Coding Interviews Whether you're prepping for FAANG, startups, or leveling up your problem-solving game—these patterns are your secret weapon. 🔍 From Prefix Sum to Dynamic Programming, each pattern unlocks a mindset shift: - 🔁 Sliding Window teaches efficiency - 🧠 Backtracking builds resilience - 🧮 DP rewards structure and foresight - 🌲 DFS/BFS mirror real-world exploration These aren't just techniques—they're thinking tools. Master them, and you’ll start seeing problems as opportunities, not obstacles. 💡 I use these patterns not just in interviews, but in classroom demos, cheat sheets, and real-world analogies that make learning stick. 📌 Save this. Share it. Teach it. Let’s make tech interviews less about memorization—and more about mastery. #CodingInterview #DSA #TechPrep #ProblemSolving #LinkedInLearning #TechWithImpact #java
To view or add a comment, sign in
-
-
Stop Using Else Nested else blocks make code messy, hard to read, and frustrating to maintain. This quick tip shows how returning early keeps your functions flat, readable, and clean. Learn to avoid unnecessary indentation, improve clarity, and write code your future self will thank you for. Perfect for developers who want clean, maintainable code in any language. #code #go #coding #javascript #python #rust #codetips #cleancode #programming
To view or add a comment, sign in
-
Day 17 of 30-day Coding Sprint Today I’ve shifted focus to one of the most efficient techniques in a developer's toolkit: The Sliding Window. 3. Longest Substring Without Repeating Characters - The Challenge: Finding the length of the longest substring where every character is unique. A naive O(n^2) approach would be too slow for large strings. - The Strategy: Optimized Sliding Window Used a Frequency Hash Array (represented as a 256-element array) to store the last-seen index of each character. Two pointers, l (left) and r (right), define the current window. - The Optimization: Instead of moving the left pointer l one by one when a duplicate is found, I "jump" 1 directly to hash[s[r]] + 1. This ensures that the window always contains unique characters in the most efficient way possible. Result: A clean O(n) time complexity with a single pass through the string. Note: The sliding window isn't just about moving pointers; it's about maintaining a state (in this case, uniqueness) and shrinking or expanding the boundaries to satisfy that state. Using a hash array to store indices turns an O(n) "shrink" into an O(1) "jump." #30DaysOfCode #DSASprint #LeetCode #JavaScript #SlidingWindow #Optimization #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