🚀 Day 9 of My LeetCode Journey — Building Data Structures from Scratch Today’s challenge: Design Linked List (LeetCode 707) 💡 What this problem is about Instead of just using a linked list, I had to design and implement it from scratch 👉 Operations implemented: get(index) addAtHead(val) addAtTail(val) addAtIndex(index, val) deleteAtIndex(index) 🧠 What I Learned: How nodes are connected using pointers (next references) Difference between singly vs doubly linked list Handling edge cases like: Empty list Invalid index Adding/deleting at head or tail ⚡ Key Insight: Arrays are easy… but Linked Lists teach you how data is actually managed in memory This problem really improved my understanding of: Traversal Node manipulation Writing clean, structured code 🔥 Takeaways: Designing data structures builds real problem-solving skills Edge cases matter more than the main logic Implementation > Theory Big thanks to Namaste DSA and Akshay Saini 🚀 for the amazing learning path Day 10 loading… 💪 #LeetCode #DataStructures #Algorithms #CodingJourney #100DaysOfCode #SoftwareEngineering #Programming #InterviewPrep #JavaScript #CodingLife #TechGrowth #ProblemSolving #Developers #LearnToCode #LinkedList #DSA #NamasteDSA #AkshaySaini
Designing Linked List from Scratch with LeetCode 707 Challenge
More Relevant Posts
-
🚀 Cracked LeetCode 18 : 4Sum — From Naive to Optimal Approach Today I worked on the classic 4Sum problem — finding all unique quadruplets that sum to a target. 🔴 Naive Approach (Brute Force) Think of checking every possible quadruplet: Use 4 loops (i, j, k, l) Check if sum == target Store unique results using a set ⏱️ Time Complexity: O(n⁴) 👉 Works, but too slow for large inputs. 🟡 Better Approach (Hashing) Fix 2 elements Use a HashSet for remaining 2 elements (like 2Sum) ⏱️ Time Complexity: O(n³) 👉 Faster, but still not optimal. 🟢 Optimal Approach (Sorting + Two Pointers) 💡 Idea: Sort the array Fix first two numbers (i, j) Use two pointers (k, l) to find remaining pair ⏱️ Time Complexity: O(n³) But much faster in practice due to pruning & skipping duplicates. 💻 Pseudo Code (Easy to Understand): sort array for i from 0 to n-1: skip duplicates for i for j from i+1 to n-1: skip duplicates for j k = j + 1 l = n - 1 while k < l: sum = arr[i] + arr[j] + arr[k] + arr[l] if sum == target: store answer k++, l-- skip duplicates for k and l else if sum < target: k++ else: l-- 🔥 Key Interview Insight 👉 “Sort + Fix elements + Reduce to 2Sum using two pointers” #DataStructures #Algorithms #Java #LeetCode #CodingInterview #100DaysOfCode
To view or add a comment, sign in
-
Waiting on outdated scrapers feels like watching a loading bar that never ends. 😱 While traditional tools struggle with JavaScript and CAPTCHAs, your data pipeline doesn’t have to. Crawlbase is built for how the web actually works today so you can focus on using data, not chasing it. What you get: 🔹 Reliable JavaScript rendering 🔹 Automatic IP rotation at scale 🔹 Intelligent handling of blocks and CAPTCHAs 🔹 Clean, structured data delivered faster Less waiting. More doing. 👉 crawlbase.com #Crawlbase #WebScraping #DataEngineering #Automation #Developers #BigData #DataExtraction #AIAutomation #MachineLearning #APIs #SaaS #TechTools #DevTools #Programming #Python #NoCode #DataPipeline #GrowthHacking
To view or add a comment, sign in
-
-
🚀 Day 15 of My DSA Journey | Top K Frequent Elements 🔥 Today, I solved one of the most important and frequently asked problems on LeetCode — Top K Frequent Elements. 💡 Problem Understanding Given an integer array, we need to return the k most frequent elements. Sounds simple, but the challenge is to do it efficiently ⚡ 🧠 Brute Force Approach Count frequency using loops Sort elements based on frequency Pick top k ⛔ Time Complexity: O(n² log n) (inefficient for large inputs) ⚡ Optimized Approach (HashMap + Sorting) Here’s what I did: ✅ Step 1: Use a HashMap to store frequency of each element ✅ Step 2: Convert map into array of (frequency, element) pairs ✅ Step 3: Sort array in descending order of frequency ✅ Step 4: Pick first k elements 📌 Example Walkthrough Input: nums = [1,1,1,2,2,3], k = 2 Frequency Map: 1 → 3 times 2 → 2 times 3 → 1 time Sorted: (3,1), (2,2), (1,3) Output: [1,2] ⏱ Complexity Analysis Time: O(n log n) (due to sorting) Space: O(n) 🔥 Key Learning HashMap is super powerful for frequency problems Converting data into sortable structure simplifies logic Always think: Can I reduce nested loops? 🙏 Thanks to my mentor and consistency mindset — improving every single day 💪Day by day, problem by problem — becoming better than yesterday 🚀 #Day15 #DSAJourney #LeetCode #Java #Coding #ProblemSolving #HashMap #Sorting #TopKFrequent #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
Stumbled across this open-source Claude Code configuration and honestly it's one of the most complete AI dev setups I've seen publicly shared. 91k+ stars. Called everything-claude-code. Here's what's packed inside: The scale of it: → 28 language-specific agents (TypeScript, Python, Go, Rust, Kotlin, Java, database and more) → 116 skills covering everything from TDD workflows to security reviews to frontend and backend patterns → 59 commands including /plan, /code-review, /e2e, /security-scan, /evolve → 34 rules across 6 languages What makes it actually useful: → 15+ hooks that auto-load context at session start and save state at session end → SQLite state store tracking session history and skill confidence scores → 14 MCP configurations for GitHub, Supabase, Vercel, Railway and more → AgentShield security scanner running 1282 tests across 102 rules What makes it practical: → Selective install so you only pull what you need → Cross-platform across Claude Code, Codex, Cursor and OpenCode Built by an Anthropic hackathon winner. That detail matters. GitHub link: https://lnkd.in/dwk28CSF #AI #Dev #ClaudeCode #OpenSource #DeveloperTools
To view or add a comment, sign in
-
-
🚀 Day 344 of solving 365 medium questions on LeetCode! 🔥 Today’s challenge: “89. Gray Code” ✅ Problem: You are given an integer n. Your goal is to generate an n-bit Gray code sequence, which is an array of 2^n integers where every adjacent pair of numbers (including the first and last numbers) differs by exactly one single bit in their binary representation. ✅ Approach (Bit Manipulation / The Formula) You could solve this using backtracking or mirroring, but there is a mathematical cheat code that solves it instantly! Find the Size: First, we need to know exactly how many numbers to generate. For an n-bit sequence, there are exactly 2^n numbers. I used a bitwise left shift (1 << n) to calculate this size instantly. The Magic Formula: The i-th number in a standard Gray code sequence can always be found using the exact formula: i ^ (i >> 1). This takes the number, shifts its bits to the right by one, and applies a bitwise XOR against the original number. List Comprehension: I packed this entire logic into a single Python list comprehension that loops from 0 up to our calculated size. It applies the magic formula to every index i, generating the perfect sequence in one go! ✅ Key Insight Bitwise operations are essentially black magic when you know the right formulas. Recognizing that Gray code has a direct integer-to-sequence mapping completely eliminates the need for messy recursive state-tracking. What looks like a complex combinatorial sequence problem is actually just a one-line math trick! ✅ Complexity Time: O(2^n) — We must iterate to generate exactly 2^n elements for the sequence. Space: O(1) — Excluding the space required for the output array, the mathematical generation uses strictly constant auxiliary memory. 🔍 Python solution attached! 🔥 Flexing my coding skills until recruiters notice! #LeetCode365 #BitManipulation #Math #Python #ProblemSolving #DSA #Coding #SoftwareEngineering
To view or add a comment, sign in
-
-
Day#17 💡Cracked LeetCode #202 – Happy Number! Ever wondered if a number can be happy? 😄 Turns out, in programming… it can! 🔍 Problem Statement: A number is called Happy if: You replace the number by the sum of the squares of its digits Repeat the process If it eventually becomes 1 → it's a Happy Number If it falls into a loop → Not Happy ❌ 🧠 Key Insight: This problem is not about math… it's about cycle detection! We keep transforming the number: 👉 If we reach 1 → Done ✅ 👉 If we revisit a number → Loop detected 🔁 Approaches: 1️⃣ Using HashSet Store visited numbers Detect loop easily Time: O(log n), Space: O(log n) 2️⃣ Floyd’s Cycle Detection (Fast & Slow Pointer) 🚀 Same concept as Linked List cycle No extra space needed Time: O(log n), Space: O(1) 💻 JavaScript Code (Floyd’s Approach): var isHappy = function(n) { const getNext = (num) => { let sum = 0; while (num > 0) { let digit = num % 10; sum += digit * digit; num = Math.floor(num / 10); } return sum; }; let slow = n; let fast = getNext(n); while (fast !== 1 && slow !== fast) { slow = getNext(slow); fast = getNext(getNext(fast)); } return fast === 1; }; 🔥 What I Learned: Cycle detection isn’t just for linked lists Mathematical problems often hide pattern recognition Always think: Can this loop forever? 📌 Example: 19 → 82 → 68 → 100 → 1 ✅ (Happy Number) #LeetCode #DSA #ProblemSolving #CodingInterview #JavaScript
To view or add a comment, sign in
-
🚀 Day 98 of LeetCode Problem Solving Journey — 100 Days LeetCode Challenge Today, I solved LeetCode #205 — Isomorphic Strings using C++, under the guidance of Trainer NEKAL SINGH SALARIA Singh at REGex Software Services. 🔍 Problem Summary: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t, with a one-to-one mapping between characters. 🧠 Approach Used (Hash Mapping): I used two hash maps to maintain a bidirectional mapping: Traverse both strings simultaneously Map characters from s → t Also ensure reverse mapping from t → s If any mapping conflict occurs → return false If traversal completes → return true This ensures a valid one-to-one correspondence. 📚 Key Learnings of the Day ✔ One-to-one mapping is key in isomorphic problems ✔ Using two maps ensures consistency ✔ Bidirectional checking prevents conflicts ✔ String traversal with mapping is a common pattern ⏱ Complexity • Time Complexity: O(n) • Space Complexity: O(1) (fixed character set) 💡 Optimization Insight: Using arrays instead of maps (for ASCII characters) can slightly improve performance. Final stretch — see you on Day 99 🚀 #Day98 #100DaysLeetCodeChallenge #LeetCode #RegexSoftwareServices #NekalSingh #ProblemSolving #DSA #CPlusPlus #CodingChallenge #ProgrammingJourney #Strings #KeepGrowing
To view or add a comment, sign in
-
-
update from previous post[https://lnkd.in/dVx_NrDQ] From "Arrow Code" to Clean Architecture. 🏹 ➡️ 🧱 I’ve hit a major turning point in my Python journey. I realized my code was starting to look like an arrow—layers upon layers of if statements and while loops pushing my logic further and further to the right. In professional dev circles, they call this Arrow Code, and it's a nightmare to maintain. Here’s how I "flattened" my latest project: ✅ Decomposition: I broke down massive, nested blocks into small, dedicated functions. Each function now does one thing well, making the main logic readable at a single glance. ✅ The "Gatekeeper" Pattern: Instead of scattered validation, I built a centralized handler to act as a security guard for all user inputs. ✅ State Management: I’m now mastering the "Baton Pass"—using return values and arguments to move data (like budgets) safely through the app instead of relying on global variables. ✅ Professional Workflow: I’m officially using Git branches and Pull Requests on GitHub to review my own work and track my architectural improvements. The goal isn't just to write code that the computer understands; it’s to write code that other humans can read. 🚀 #CleanCode #Python #SoftwareEngineering #Refactoring #CodingJourney #BuildInPublic
To view or add a comment, sign in
-
-
Day 24 of #100DaysOfCode I stared at this problem for 40 minutes trying every possible target value. Then one insight — borrowed from basic statistics — made it click instantly. 🧩 The Problem: Minimum Operations to Make a Uni-Value Grid (LeetCode 2033 — Medium) Given a 2D grid and a fixed step value x, transform every element to the same value using the minimum number of add/subtract operations. My first instinct? Try every possible target. Loop through everything. Classic overthinking. 😅 💡 The Key Insight — Why the Median? The median minimizes the sum of absolute differences. This is a well-known statistics fact — and it maps perfectly to this problem. Instead of brute-forcing every target, the strategy is simple: → Flatten the 2D grid into a 1D array → Sort it → Pick the middle element (median) as the target → Count total operations using the absolute difference divided by x No guessing. No unnecessary loops. Just math doing the heavy lifting. ⚠️ The Constraint Check Nobody Talks About Before applying any operations — check if all elements share the same remainder when divided by x. If they don't, it's mathematically impossible to make the grid uni-value. Return -1 immediately and save the computation entirely. This "fail fast" mindset is just as important as the algorithm itself. 📈 Complexity Breakdown → Flatten + Sort → O(n log n) → Single pass to count operations → O(n) → Space → O(n) for the flattened array Simple, clean, and efficient. 🧠 What This Problem Reinforced ✅ Greedy thinking with median optimization ✅ Handle impossible cases before computation — fail fast ✅ Transform 2D problems into simpler 1D forms ✅ Let math do the heavy lifting before writing a single loop The best solutions often come from asking: "What does math already know about this?" On to the next challenge 💪 👇 What's a problem where a simple insight saved you from overcomplicating things? Drop it in the comments — would love to learn from your experience! #100DaysOfCode #LeetCode #DSA #Java #ProblemSolving #CodingJourney #SoftwareEngineering #Programming
To view or add a comment, sign in
-
-
🚀 Day 29 LeetCode Problem Solved: Longest Consecutive Sequence (128) Today I solved an interesting Data Structures & Algorithms problem on LeetCode. 💻 🔹 Problem: Given an unsorted array of integers, find the length of the longest consecutive elements sequence in O(n) time complexity. 🔹 Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 👉 The longest consecutive sequence is [1,2,3,4]. 🔹 Approach: Instead of sorting the array (which takes O(n log n)), I used a HashSet to achieve O(n) time complexity. ✔ Store all numbers in a HashSet ✔ Identify the start of a sequence (num - 1 not present in the set) ✔ Expand the sequence forward (num + 1, num + 2...) ✔ Track the maximum length 🔹 Complexity: ⏱ Time Complexity: O(n) 📦 Space Complexity: O(n) 💡 Key Learning: Using HashSet efficiently can help optimize problems that involve searching and sequence detection. Excited to keep learning and improving problem-solving skills! 🚀 #leetcode #coding #java #datastructures #algorithms #softwaredeveloper #programming #codingjourney
To view or add a comment, sign in
-
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