𝗗𝗮𝘆 𝟲𝟳/𝟭𝟬𝟬 — 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁 𝗤𝘂𝗲𝘂𝗲 𝘂𝘀𝗶𝗻𝗴 𝗦𝘁𝗮𝗰𝗸𝘀 Day 67. Building data structures from scratch. Can you build a queue using only stacks? Yes. Should you? Probably not. But it teaches you something valuable. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ #𝟮𝟯𝟮: Implement Queue using Stacks (Easy) 𝗧𝗵𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲: Implement a FIFO queue using only LIFO stacks. Operations: push, pop, peek, empty. The problem? Stacks are last-in-first-out. Queues are first-in-first-out. Opposite behaviors. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: Two stacks: in and out. My solution keeps elements in reverse order in the in stack, so the oldest element is always on top. On push: Move all elements from in to out Push new element to in Move everything back from out to in Pop and peek? Just operate on in directly. Time: O(n) per push, O(1) for pop/peek 𝗪𝗵𝘆 𝗜𝘁 𝗠𝗮𝘁𝘁𝗲𝗿𝘀: Design problems force you to understand data structures deeply. Not just use them—build them. This isn't the most efficient approach, but it works. And understanding trade-offs is what separates good developers from great ones. 𝗖𝗼𝗱𝗲: https://lnkd.in/gcASkCjm 𝗗𝗮𝘆 𝟲𝟳/𝟭𝟬𝟬 ✅ 𝟲𝟳 𝗱𝗼𝘄𝗻. 𝟯𝟯 𝘁𝗼 𝗴𝗼. #100DaysOfCode #LeetCode #Queue #Stack #DataStructures #SystemDesign #Algorithms #CodingInterview #Programming #Java #DesignProblems
More Relevant Posts
-
Day 38 of #75DaysofLeetCode 🚀 Cracked LeetCode 236 – Lowest Common Ancestor of a Binary Tree! Understanding trees becomes powerful when you master problems like LCA 🌳 💡 Problem Insight: Given a binary tree, find the lowest node that has both p and q as descendants. 🔍 Key Idea: Instead of storing paths, we can solve this using a simple recursive DFS: If current node is null, p, or q → return it Search left and right subtree If both sides return non-null → 🎯 current node is the LCA Otherwise → return the non-null side ⚡ Why this works? Because the first node where both p and q appear in different subtrees is their lowest common ancestor. ⏱ Complexity: Time: O(N) Space: O(H) 📌 Takeaway: You don’t always need extra data structures—smart recursion can simplify complex tree problems! #LeetCode #DataStructures #Java #CodingInterview #BinaryTree #DFS #TechJourney
To view or add a comment, sign in
-
-
Data Structures Cheatsheet — Everything You Need in One Place! Whether you're preparing for technical interviews or brushing up on CS fundamentals, understanding data structures is non-negotiable. Here's a quick breakdown of the 7 essential ones every developer should know: 📦 Array → Contiguous memory, index-based access. Simple but powerful. 🔗 Linked List → Dynamic size, efficient insertions & deletions. Great when memory flexibility matters. 📚 Stack → Last In, First Out (LIFO). Think function calls & undo operations. 🚶 Queue → First In, First Out (FIFO). Perfect for task scheduling & message passing. #️⃣ Hash Table → Key-value pairs with O(1) average lookup. Every backend dev's best friend. 🌳 Tree → Hierarchical structure with parent-child relationships. Used in searching, sorting & databases. 🕸️ Graph → Vertices + Edges. Models networks, social connections & real-world relationship #DataStructures #DSA #Java #Programming #TechInterview #ComputerScience #100DaysOfCode #BackendDevelopment #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
-
Data Structures Cheatsheet — Everything You Need in One Place! Whether you're preparing for technical interviews or brushing up on CS fundamentals, understanding data structures is non-negotiable. Here's a quick breakdown of the 7 essential ones every developer should know: 📦 Array → Contiguous memory, index-based access. Simple but powerful. 🔗 Linked List → Dynamic size, efficient insertions & deletions. Great when memory flexibility matters. 📚 Stack → Last In, First Out (LIFO). Think function calls & undo operations. 🚶 Queue → First In, First Out (FIFO). Perfect for task scheduling & message passing. #️⃣ Hash Table → Key-value pairs with O(1) average lookup. Every backend dev's best friend. 🌳 Tree → Hierarchical structure with parent-child relationships. Used in searching, sorting & databases. 🕸️ Graph → Vertices + Edges. Models networks, social connections & real-world relationship #DataStructures #DSA #Java #Programming #TechInterview #ComputerScience #100DaysOfCode #BackendDevelopment #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
-
I still remember the first time I heard about LRU Cache… It sounded simple — “remove least recently used item” 🤔 But when I actually tried to build it… That’s when the real learning started. 🧩 The Problem Design a system where: get(key) → return value if exists put(key, value) → insert/update If capacity is full → remove least recently used And the twist? ⚡ Everything must run in O(1) time. 💡 My Thought Process At first, I thought: 👉 “Let’s just use an array or list…” But then reality hit: Searching = O(n) ❌ Updating order = costly ❌ So I asked myself: 👉 What combination gives both fast access AND fast updates? 🚀 The Breakthrough I used: HashMap → for O(1) access Doubly Linked List → for O(1) insertion & deletion 🧠 How It Works Most recently used → stays near head Least recently used → near tail 🔹 On get(key) If not found → -1 If found: Remove node from its position Move it to head (recently used) 🔹 On put(key, value) If key exists: Update value Move to head If new key: If capacity full: Remove node before tail (LRU) Insert new node at head ⚡ Complexity 💡 Time Complexity (TC): get() → O(1) put() → O(1) 💡 Space Complexity (SC): HashMap + Linked List → O(capacity) 🌱 What This Problem Taught Me This wasn’t just about coding… It taught me: 👉 The real power comes from combining data structures 👉 Clean design > brute force 👉 Thinking in systems is what separates good from great engineers Coming from a UI/UX background, building something this low-level felt like a big win for me 🚀 And honestly… this is what makes the journey exciting. If you're also learning DSA or system design fundamentals, keep going — these concepts show up everywhere in real-world systems. Let’s grow together 🤝 #LRUCache #SystemDesign #DataStructures #Java #CodingJourney #SoftwareEngineering #TechLearning
To view or add a comment, sign in
-
-
This project I made to solve the problem of 𝘂𝗻𝗺𝗮𝗻𝗮𝗴𝗲𝗮𝗯𝗹𝗲 𝗳𝗶𝗹𝗲 𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲𝘀 and the 𝘁𝗼𝘁𝗮𝗹 𝗹𝗮𝗰𝗸 𝗼𝗳 𝘃𝗶𝘀𝗶𝗯𝗶𝗹𝗶𝘁𝘆 into how documents are actually consumed 🛠️📉 Through this build, I focused on mastering 𝗢𝗢𝗣 𝗽𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲𝘀 and robust 𝗦𝘆𝘀𝘁𝗲𝗺 𝗗𝗲𝘀𝗶𝗴𝗻 🏗️. I adopted a 𝗦𝗲𝗿𝘃𝗶𝗰𝗲-𝗥𝗲𝗽𝗼𝘀𝗶𝘁𝗼𝗿𝘆 𝗽𝗮𝘁𝘁𝗲𝗿𝗻 to strictly decouple the UI from the data logic, ensuring a clean, 𝘂𝗻𝗶𝗱𝗶𝗿𝗲𝗰𝘁𝗶𝗼𝗻𝗮𝗹 𝗳𝗹𝗼𝘄 that is easy to maintain and scale 🔄 A key technical highlight: I implemented a 𝗵𝗶𝗴𝗵-𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗿𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝘀𝘆𝘀𝘁𝗲𝗺 that maps local file paths to a 𝗦𝗤𝗟𝗶𝘁𝗲 𝗯𝗮𝗰𝗸𝗲𝗻𝗱 🚀💾. By storing 𝗿𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲𝘀 instead of heavy binaries, I kept the database 𝗹𝗶𝗴𝗵𝘁𝘄𝗲𝗶𝗴𝗵𝘁 𝗮𝗻𝗱 𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝘁 while still enabling granular, real-time 𝗰𝗹𝗶𝗰𝗸𝘀𝘁𝗿𝗲𝗮𝗺 𝗮𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 🖱️📊 To ensure complete 𝗽𝗿𝗶𝘃𝗮𝗰𝘆 𝗮𝗻𝗱 𝗱𝗮𝘁𝗮 𝗼𝘄𝗻𝗲𝗿𝘀𝗵𝗶𝗽, I designed this as a 𝗹𝗼𝗰𝗮𝗹 𝗺𝗮𝗰𝗵𝗶𝗻𝗲 𝗲𝘅𝗲𝗰𝘂𝘁𝗮𝗯𝗹𝗲 💻🔒. All sensitive documentation and behavioral data remain secure and 𝗻𝗲𝘃𝗲𝗿 𝗹𝗲𝗮𝘃𝗲 𝘁𝗵𝗲 𝗹𝗼𝗰𝗮𝗹 𝗲𝗻𝘃𝗶𝗿𝗼𝗻𝗺𝗲𝗻𝘁. 𝗞𝗲𝘆 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: → 𝗠𝗶𝗰𝗿𝗼-𝗧𝗲𝗹𝗲𝗺𝗲𝘁𝗿𝘆: Tracks unique pages visited to calculate a "Reading Percentage" metric (Unique Pages ÷ Total Pages) → 𝗖𝗿𝗼𝘀𝘀-𝗣𝗹𝗮𝘁𝗳𝗼𝗿𝗺 𝗥𝗲𝗹𝗶𝗮𝗯𝗶𝗹𝗶𝘁𝘆: Dynamic path resolution via os.path.join keeps it fully OS-agnostic → 𝗦𝗲𝗮𝗿𝗰𝗵𝗮𝗯𝗹𝗲 𝗘𝗰𝗼𝘀𝘆𝘀𝘁𝗲𝗺: Replaces scattered folders with a centralized, tag-based filtering system Check out the below to see the architectural breakdown visually and discussion about future scope 🔍 : "https://lnkd.in/gTtUtn9f" 𝗧𝗲𝗰𝗵 𝗦𝘁𝗮𝗰𝗸: 🐍 Python | 📊 Streamlit | 🗄️ SQLite | 📑 PyMuPDF | 🛠️ OS & Pathlib Source Code : "https://lnkd.in/gWfKidYg" #Python #SystemDesign #OOP #SQLite #SoftwareEngineering #DataPrivacy #LocalFirst #CodingJourney DEMO :
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
-
-
What Is Pseudocode and How to Write It What is pseudocode? It's a powerful tool that bridges the gap between human thinking and computer programming. By using plain language to outline algorithms, pseudocode allows you to focus on the logic of your code without getting bogged down by syntax. Whether you're a novice coder or an experienced programmer, understanding pseudocode can significantly enhance your ability to plan and execute complex projects. In this guide, we’ll explore the fundamentals of pseudocode, its structure, and best practices to help you write clear and efficient algorithms. Join us as we unlock the potential of pseudocode and elevate your programming skills!
To view or add a comment, sign in
-
What Is Pseudocode and How to Write It What is pseudocode? It's a powerful tool that bridges the gap between human thinking and computer programming. By using plain language to outline algorithms, pseudocode allows you to focus on the logic of your code without getting bogged down by syntax. Whether you're a novice coder or an experienced programmer, understanding pseudocode can significantly enhance your ability to plan and execute complex projects. In this guide, we’ll explore the fundamentals of pseudocode, its structure, and best practices to help you write clear and efficient algorithms. Join us as we unlock the potential of pseudocode and elevate your programming skills!
To view or add a comment, sign in
-
Day 81/365 – Mini Parser Today’s problem dives into **parsing + stacks** — very real-world and interview-relevant. 🔍 **Problem** Convert a string like: 👉 `"[123,[456,[789]]]"` into a nested data structure. 💡 **Key Insight** Use a **stack** to handle nested structures. * `[` → start a new list * `]` → close current list * `,` → separator * digits → build numbers 🧠 **Approach** 1️⃣ If no `[` → it's just a single number 2️⃣ Use stack to track nested lists 3️⃣ Build numbers digit by digit 4️⃣ On `]` → attach current list to parent ⚡ **Why Stack?** Because nesting is **LIFO** 👉 Last opened list closes first 📊 **Complexity** ⏱ Time: O(n) 📦 Space: O(n) ✨ **Key Learning** 👉 Parsing problems = **state + stack + careful handling** 👉 This pattern appears in: * JSON parsing * Expression evaluation * Compiler design #Day81 #365DaysOfCode #LeetCode #Stack #Parsing #Algorithms #DSA #CodingInterview #Java #ProblemSolving
To view or add a comment, sign in
-
-
These 6 codebases taught me more than my CS degree: _____ Btw grab my 12 systems design tradeoffs sheet: https://dub.sh/12-patterns Follow Alexandre Zajac for software and AI 🫡 _____ 0. 𝗥𝗲𝗱𝗶𝘀 (simplicity as architecture): ~60K lines of C powering millions of production systems. Single-threaded by design. No clever tricks. Just proof that you don't need complexity to scale. Read ae.c — 300 lines that handle the entire event loop. 1. 𝗦𝗤𝗟𝗶𝘁𝗲 (test like lives depend on it): 150K lines of source code. 92 million lines of tests. 100% branch coverag; not line coverage, branch coverage. It runs on every phone, every browser, every OS. The testing philosophy alone is worth studying. 2. 𝗚𝗶𝘁 (data model > features): Content-addressable storage. Blobs, trees, commits, refs. Four objects run the entire system. Linus designed the data model first and features became trivial. If your system feels complicated, your data model is wrong.' 3. 𝗤𝘂𝗮𝗸𝗲 𝗜𝗜𝗜 𝗔𝗿𝗲𝗻𝗮 (performance is a design choice): Real-time 3D in 1999 on hardware weaker than your watch. Every allocation was intentional. Every branch was measured. Home of the famous fast inverse square root. This is what "optimized" actually looks like. 4. 𝗚𝗼 𝘀𝘁𝗮𝗻𝗱𝗮𝗿𝗱 𝗹𝗶𝗯𝗿𝗮𝗿𝘆 (readability is a feature): No magic. No macros. No inheritance chains. Written to be read by humans first, compilers second. Open net/http, you'll understand a production HTTP server in an hour. Now try that with Java's equivalent. 5. 𝗟𝗶𝗻𝘂𝘅 𝗸𝗲𝗿𝗻𝗲𝗹 (modularity at impossible scale): 28M+ lines. Thousands of contributors. Runs on watches, supercomputers, and Mars rovers. The VFS layer, one interface, hundreds of filesystems. Proof that good abstractions let a system grow for 30+ years. None of them are short. None of them are easy. None of them are optional if you want to get serious. Reading great code > writing more code. Pick one codebase. Spend 30 minutes a day reading it. In a month, you'll write code differently. Which codebase shaped how you think?
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