Today I practiced the "Middle of the Linked List" problem while working on Data Structures in JavaScript. The challenge was to return the middle node of a singly linked list. If the list has two middle nodes, the second one should be returned. Instead of counting the length of the list first, I implemented the Fast and Slow Pointer technique: Slow pointer moves one step at a time Fast pointer moves two steps at a time When the fast pointer reaches the end, the slow pointer naturally lands at the middle of the list. This approach solves the problem in O(n) time and O(1) space, which is much more efficient than calculating the list length separately. Working through these problems is helping me strengthen my understanding of pointers, traversal patterns, and algorithmic thinking in JavaScript. #javascript #dsa #datastructures #algorithms #leetcode #programming #softwareengineering
JavaScript Linked List Middle Node Solution with Fast and Slow Pointers
More Relevant Posts
-
🚀 LeetCode Problem Solved – Reverse String Solved the Reverse String problem on LeetCode using JavaScript with an optimized in-place approach. ✅ Key Idea: Reverse the string by swapping characters from the start and end of the same array, modifying it directly without creating any extra array. 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(1) – No extra space used (in-place modification) 💡 Approach: • Use a two-pointer technique • One pointer starts from the beginning of the array • Another pointer starts from the end • Swap characters and move both pointers toward the center until they meet 📊 Result ✔️ All test cases passed ⚡ Runtime: 0 ms 📦 Space Complexity: O(1) Consistently practicing problems like this helps strengthen Data Structures & Algorithms fundamentals and improves problem-solving skills for coding interviews. #leetcode #javascript #dsa #twopointers #programming #codingpractice #softwareengineering
To view or add a comment, sign in
-
-
Priority Order in JavaScript Day 216 Today Today I learned about the Priority Queue. It is a very important concept in data structures. In a normal queue the rule is first in first out. But in a priority queue the element with the highest priority is processed first. Think of a hospital emergency room. A patient with a serious injury gets treated before someone with a cold even if the person with the cold arrived earlier. This is exactly how a priority queue works. I learned that there are two ways to implement this. You can use an array and sort it every time but that is slow. The best way is using a Heap. Using a Heap makes adding and removing elements very fast because the time complexity is log n. JavaScript does not have a built in priority queue like some other languages. This means we have to build it ourselves using classes. This is a great way to practice logic building and understand how things work under the hood. A very helpful tip for interviews is that if a question asks for the Kth smallest or Kth largest element you should think of using a priority queue or a heap. It makes the solution much more efficient. Today I solved these LeetCode questions: 215 Kth Largest Element in an Array 703 Kth Largest Element in a Stream #DSAinJavaScript #365daysOfCoding #JavaScriptLogic #LeetCode #DataStructures #PriorityQueue #CodingInterview #ProgrammingDaily #SoftwareEngineering #TechLearning #WebDevelopment #LogicBuilding #ProblemSolving #JavaScriptDev #JSCode #ArrayLogic #HeapDataStructure #AlgorithmDesign #CodingChallenge #BinaryHeap
To view or add a comment, sign in
-
📌 #69 DailyLeetCodeDose Today's problem: 25. Reverse Nodes in k-Group – 👹 Hard Interesting fact about me – linked lists were my favorite topic in the Algorithms and Data Structures course at university. So for the 69th problem I got something special – a hard linked list problem 😈 Honestly, the problem description is written in probably the most confusing way possible. But the core idea is actually pretty simple: you just need to reverse nodes in groups of size k inside the list. In practice, this is only slightly more complicated than reversing the entire linked list – the main difference is that when you reverse a group, you must keep track of the new head of that reversed group so you can correctly reconnect it with the previous and next parts of the list. It may look scary at first glance, but in reality it's not that bad. The most important thing is not to get lost in pointer manipulation 🦍 https://lnkd.in/daAPrhbP #DailyLeetCodeDose #LeetCode #JavaScript #Algorithms #ProblemSolving #Coding
To view or add a comment, sign in
-
-
59.8 MB JavaScript source leak of Claude Code. Surprisingly, it was a human error that happened during the release packaging. No customer data, API credentials, or model weights were exposed. But, 512,000 lines of TypeScript across ~1,900 files were exposed. It includes the query engine, tool system, multi-agent orchestration logic, and context compaction. But the amazing part? Someone noticed this as an opportunity. The guy's name is Sigrid Jin, a Korean Developer. He developed Claw Code, a clean-room Python rewrite of Claude Code's agent harness. He published it on GitHub where the repo reached 50k stars in just 2 hours. If you want the GitHub URL, comment "Claw Code" and I will share it with you.
To view or add a comment, sign in
-
-
I compared the same logic in JS and Rust. The result? The "complex" Rust version wasn't just drastically faster — it was actually shorter and cleaner. If you’ve worked with JavaScript, Python, or Java, you’ve likely encountered the classic problem of counting how many times each character appears in a string. In JavaScript, the typical approach looks like this: if (map.has(ch)) { map.set(ch, map.get(ch) + 1); } else { map.set(ch, 1); } While this seems straightforward, there’s a hidden performance flaw: The Double Lookup & Value Copying. This one-liner requires extra work from the engine: 1️⃣ map.get(ch): Calculates the hash, traverses memory, finds the bucket, and extracts a copy of the number. 2️⃣ + 1: Creates a brand-new number primitive in memory. 3️⃣ map.set(ch, ...): Calculates the hash again, traverses memory again, finds the same bucket, and copies the new number back into it. Now, let's see how Rust handles the same logic: *counts.entry(ch).or_insert(0) += 1; This isn't just syntactic sugar; it utilizes Rust's Entry API, designed for maximum hardware efficiency. Here’s why it’s blazingly fast: - It calculates the hash exactly once. - It locates the memory bucket exactly once. - It returns a &mut (a direct mutable pointer/reference) right to that memory slot. The += operator modifies the primitive value in-place without copying it out or needing a .set() method to put it back. This results in code that reads like a high-level script but executes with the speed of a systems language. Zero-cost abstractions at their finest! #Rust #JavaScript #Programming #Performance #SoftwareEngineering #WebDev #RustLang
To view or add a comment, sign in
-
-
Sharing beginner-friendly notes on Advanced Functions in JavaScript 🧠 Covered two of the most important concepts every JS developer needs to master, Closures and Higher-Order Functions. The guide walks through how closures "remember" their lexical scope, enabling data privacy, memoization, and function factories. Also explored essential Higher-Order Functions like map, filter, reduce, and practical utilities like debounce, throttle, curry, and compose with clear examples and visual diagrams. A practical guide for understanding how functions truly work under the hood. Feedback and suggestions are welcome! #JavaScript #Coding #Learning #Programming
To view or add a comment, sign in
-
Project 2 is live. ✅ RAG Document Assistant — upload any PDF, ask questions, get answers in English and Spanish. Stack: → FastAPI + LangChain + Claude API + Pinecone → Next.js frontend → Two separate deployments: Railway + Vercel This one taught me more than any course ever could. 🔗 https://lnkd.in/gUKKEAzQ 💻 https://lnkd.in/gSg_WPA3 #AIEngineer #RAG #BuildInPublic #AnthropicClaude #Python
To view or add a comment, sign in
-
📣 𝗡𝗲𝘅𝘁 𝗕𝗹𝗼𝗴 𝗶𝘀 𝗛𝗲𝗿𝗲! ⤵️ Understanding Object-Oriented Programming in JavaScript 🧩💻 One of the most important programming concepts—explained in simple, beginner-friendly terms. 🔗 𝗥𝗲𝗮𝗱 𝗵𝗲𝗿𝗲: https://lnkd.in/gvH9UgXb 𝗧𝗼𝗽𝗶𝗰𝘀 𝗰𝗼𝘃𝗲𝗿𝗲𝗱 ✍🏻: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ ⇢ What Object-Oriented Programming really means ⇢ Why real programs need objects ⇢ Class vs Object (blueprint vs real instance) ⇢ How constructors initialize data ⇢ Adding methods (behavior inside objects) ⇢ Encapsulation in simple terms ⇢ Organizing code for scalability ⇢ How OOP makes large applications manageable 💬 If you’re starting with JavaScript or trying to understand how real applications are structured, this will help you build a strong foundation. #ChaiAurCode #JavaScript #OOP #WebDevelopment #100DaysOfCoding
To view or add a comment, sign in
-
-
🚀 Starting my journey in web development! I’m happy to share my first project — a Flask CRUD Web Application 💻 🔹 Built using: Flask, MySQL, HTML, CSS 🔹 Features: Create, Read, Update, Delete operations 🔹 Deployed using Render 🔹 Source code available on GitHub 🌐 Live Demo: https://lnkd.in/gXdhjUYY 💻 GitHub Repo: https://lnkd.in/gRbe_2YB This is just the beginning — looking forward to building more advanced and impactful projects ahead! #Flask #Python #WebDevelopment #BeginnerProject #svhec Dr. Muralisankar Kumaresan Guide KABILESH RAMAR
To view or add a comment, sign in
-
🚀 Understanding Memoization in JavaScript When working with functions that perform heavy calculations, running the same computation again and again can slow down your application. This is where Memoization becomes very useful. Memoization is an optimization technique where the result of a function is stored after it is executed for the first time. If the function is called again with the same input, the stored result is returned instead of recalculating it. This helps to: ✔️ Reduce unnecessary computations ✔️ Improve performance ✔️ Make applications faster and more efficient In this example, once a value is calculated, it is saved in the cache, so the function doesn’t need to compute it again. In simple terms, Memoization remembers previous results to make future operations faster. It’s commonly used in recursive algorithms, dynamic programming, and performance optimization in JavaScript applications. #JavaScript #WebDevelopment #FrontendDevelopment #Programming #Coding #SoftwareDevelopment #Developers #TechLearning #LearnJavaScript #PerformanceOptimization #CodingJourney #TechCommunity
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