🚀 #Day30/300 — Mastering DSA Challenge Continuing my 300-day journey to strengthen my Data Structures & Algorithms skills using Java. 📌 Daily Goals • Solve at least 1 problem every day • Focus on pattern recognition and optimized solutions • Share consistent learning updates along the journey 🧠 Today’s Problem: Find Median from Data Stream Solved this problem using the Two Heaps approach (Max Heap + Min Heap). Maintained one heap for the smaller half of elements and another for the larger half to efficiently calculate the median at any point. 💡 Key Takeaways: • Use Max Heap for the left half and Min Heap for the right half • Balance both heaps to maintain size difference ≤ 1 • Median can be retrieved in O(1) time • Time Complexity per insertion: O(log n) This problem strengthened my understanding of heap balancing, stream processing, and real-time median calculation. Staying consistent and improving every day in this 300-day DSA journey. 💪 #DSA #Java #ProblemSolving #BackendDeveloper #FullStackDeveloper #300DaysChallenge #LearningInPublic #Heap #PriorityQueue #Algorithms #SDE #React #ReactNative #JavaFullStack #SpringBoot
Mastering DSA with Java: Day 30
More Relevant Posts
-
🚀 #Day31/300 — Mastering DSA Challenge Continuing my 300-day journey to strengthen my Data Structures & Algorithms skills using Java. 📌 Daily Goals • Solve at least 1 problem every day • Focus on pattern recognition and optimized solutions • Share consistent learning updates along the journey 🧠 Today’s Problem: Smallest Range in K Lists Solved this problem using a Min Heap (Priority Queue) approach along with tracking the current maximum element. The idea is to always consider one element from each list and minimize the range between the minimum and maximum values. 💡 Key Takeaways: • Use Min Heap to track the smallest element among K lists • Keep updating the current maximum to calculate range • Helps in solving multi-pointer problems efficiently • Time Complexity: O(n log k) This problem strengthened my understanding of heap-based merging, range optimization, and handling multiple sorted lists. Staying consistent and improving every day in this 300-day DSA journey. 💪 #DSA #Java #ProblemSolving #BackendDeveloper #FullStackDeveloper #300DaysChallenge #LearningInPublic #Heap #PriorityQueue #Algorithms #SDE #React #ReactNative #JavaFullStack #SpringBoot
To view or add a comment, sign in
-
-
🚀 DSA Learning Update – Reverse Words in a String Today I solved “Reverse Words in a String” (LeetCode #151) using a clean and practical approach. 🔍 Problem Insight The goal is not just reversing a string, but: Removing extra spaces Keeping only single spaces between words Reversing the order of words 💡 My Approach Trim the string to remove leading/trailing spaces Split the string using " " Traverse from right → left Skip empty strings (caused by multiple spaces) Build the result using StringBuilder 📌 Core Logic String str = s.trim(); String[] ar = str.split(" "); StringBuilder ans = new StringBuilder(); for (int i = ar.length - 1; i >= 0; i--) { if (ar[i].equals("")) continue; if (ans.length() > 0) { ans.append(" "); } ans.append(ar[i]); } return ans.toString(); 📌 Example Input: " hello world " Output: "world hello" 🧠 Key Learnings ✔ Always handle edge cases (especially spaces in strings) ✔ split(" ") can create empty values → must filter them ✔ Reversing traversal simplifies the logic ✔ Clean formatting matters as much as correctness ✨ Takeaway Even simple string problems can test attention to detail. Learning how to handle edge cases properly is a big step toward writing robust code. #DSA #LeetCode #Java #ProblemSolving #CodingJourney #LearnInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Backend Learning | Pagination Strategies (Offset vs Cursor-Based) While working on backend systems, I recently explored how to efficiently handle large datasets using pagination. 🔹 The Problem: • Fetching large datasets increases response time • High memory and database load • Poor user experience 🔹 What I Learned: • Offset-Based Pagination: → Uses LIMIT & OFFSET → Simple but slow for large data • Cursor-Based Pagination: → Uses a unique cursor (like ID or timestamp) → Faster and more efficient for large datasets 🔹 Key Insights: • Offset → Easy but not scalable • Cursor → Scalable and performant • Cursor avoids skipping large rows 🔹 Outcome: • Improved API performance • Efficient data fetching • Better user experience Handling large data is not about fetching more — it’s about fetching smartly. 🚀 #Java #SpringBoot #BackendDevelopment #SystemDesign #APIDesign #Pagination #LearningInPublic
To view or add a comment, sign in
-
-
DSA Day 4 – Simple Problem, Important Insight Today I solved the “Contains Duplicate” problem on LeetCode. Problem: Check if any element appears more than once in an array. Initial Thought: -> Use nested loops to compare every pair -> Time Complexity: O(n²) ❌ Optimized Approach: -> Used HashMap to track elements -> While iterating, check if element already exists -> If yes → duplicate found Time Complexity: -> O(n) -> Space Complexity: O(n) Key Learning: -> Not every problem needs complex logic -> Choosing the right data structure makes a big difference -> Hashing is one of the most powerful tools in DSA What I Realized: Sometimes the simplest problems teach the most important concepts. Thanks to Pulkit Aggarwal sir for guiding me in DSA and helping me build strong fundamentals. Staying consistent, one day at a time. #DSA #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 30 Days of DSA — Day 1 Starting today, I'm committing to solving one Data Structures & Algorithms problem every day for the next 30 days. Why this challenge? • Strengthen problem-solving skills • Build consistency • Learn in public 📌 Day 1 Problem: Bubble sort implementation 🧠 Approach: Compared adjacent elements and swapped them if they were in the wrong order. Repeated this process multiple times until the array was sorted. ⏱️ Time Complexity: O(n²) 💡 Key Learning: Bubble Sort is simple but inefficient for large datasets. Great for understanding sorting fundamentals. Let's see where this journey takes me. If you're also working on DSA, feel free to connect or share your approach 👇 #30DaysOfDSA #Java #SpringBoot #JavaDeveloper #DSA #DataStructures #Algorithms #CodingChallenge #ProblemSolving #SoftwareEngineer #BackendDeveloper #LearningInPublic #CodingJourney #Developers #TechCommunity
To view or add a comment, sign in
-
-
#Day48 – Visualizing Data Structures for Better Understanding 🎯 Special thanks to Harshit T Sir for building such an amazing learning tool that makes complex concepts simple🙌 I explored the Collections Visualizer, a powerful tool that helps in understanding how data structures actually work internally — not just theoretically, but visually. 💡 Key Learnings: ✔ Visualized how ArrayList, LinkedList, ArrayDeque, and PriorityQueue work internally ✔ Understood memory representation instead of just code execution ✔ Saw how PriorityQueue uses Min Heap internally ✔ Observed how elements are inserted, swapped, and removed step-by-step ✔ Learned that visual learning makes complex structures much easier to grasp #Java #DataStructures #CollectionsFramework #LearningByDoing #CodingJourney #Consistency #DSA
To view or add a comment, sign in
-
📘 OOPs… or “How Java made my life both easier and confusing” 😄 Initially, I thought: 👉 “OOPs means just writing code using objects instead of functions… simple!” Then I started digging deeper 👇 🚗 The example that clicked for me: Car = Object ✔ Properties → color, speed, fuel ✔ Behaviors → start(), accelerate(), brake() 💻 So in Java: 👉 We create a class (blueprint) 👉 Then create an object using the new keyword Simple understanding: 📄 Class = Plan 🚗 Object = Real thing 💡 Then came the famous 4 pillars (things got interesting 😅): ✔ Inheritance → Child class takes parent features ✔ Abstraction → Hide complexity, show only what's needed ✔ Polymorphism → One method, many forms ✔ Encapsulation → Protect data using getters/setters 😵 My realization: Before OOPs → Messy code After OOPs → Organized… but requires thinking 😄 🔥 Why OOPs actually matters: ✔ Easier to understand ✔ Code reuse (no need to rewrite logic) ✔ More secure ✔ Easy to scale (future features become manageable) 💭 Lesson learned: “OOPs is not just coding… it’s a way of thinking.” Still learning… but improving step by step 🚶♂️ #Java #OOP #Learning #BackendDeveloper #CodingLife
To view or add a comment, sign in
-
-
🚀 DSA Journey — Day 17: Mastering Binary Search (LeetCode 704) Today I worked on one of the most fundamental and powerful algorithms in DSA — Binary Search. 🔍 Problem Understanding Given a sorted array, we need to efficiently find the index of a target element. If it exists, return its index; otherwise, return -1. 💡 Brute Force Approach Traverse the array linearly Compare each element with target Time Complexity: O(n) ⚠️ Not optimal for large datasets ⚡ Optimized Approach — Binary Search Since the array is sorted, we can eliminate half of the search space in every step. 👉 Steps: Initialize start = 0, end = n-1 Find middle: mid = (start + end) / 2 Compare: If nums[mid] == target → return index If target < mid → move left (end = mid - 1) If target > mid → move right (start = mid + 1) Repeat until found or search space ends 🧠 Example Walkthrough Array: [-1,0,3,5,9,12], Target: 9 mid = 2 → value = 3 → move right mid = 4 → value = 9 → ✅ Found ⏱️ Complexity Analysis Time Complexity: O(log n) Space Complexity: O(1) 🎯 Key Learning Binary Search is not just a problem — it's a pattern. Understanding this deeply will help in: Searching problems Optimization problems Many advanced DSA questions 🙏 Gratitude Grateful for the consistency and learning mindset every day 🙌 📈 Consistency is the real game changer. One problem a day = big results. #DSA #BinarySearch #LeetCode #CodingJourney #Java #ProblemSolving #Consistency #Learning #TechJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 50 of My DSA Journey Today I reached a major milestone—Day 50! To celebrate, I tackled "Design Linked List" on LeetCode using Java. This was a great exercise in understanding the fundamental mechanics of data structures. Problem Summary The task is to manually implement a Singly or Doubly Linked List from scratch. This includes creating functions to: Get the value of a node at a specific index. Add a node at the head and tail. Add a node before a specific index. Delete a node at a specific index. 🛠️ My Approach I chose to implement a Singly Linked List using a Sentinel (Dummy) Node. Sentinel Node: Used a dummy head to simplify edge cases (like adding or deleting at the very beginning of the list). Pointer Management: Carefully tracked the next references to ensure the chain remains intact during insertions and deletions. Size Tracking: Maintained a size variable to perform quick bounds checking for index-based operations. Complexity Analysis Time Complexity: * $O(1)$ for addAtHead. $O(n)$ for get, addAtIndex, and deleteAtIndex (where $n$ is the length of the list). Space Complexity: $O(n)$ to store the $n$ nodes of the linked list. Result Accepted! Successfully handled the zero-indexing and edge cases for an efficient implementation. Key Learning Manual Memory Logic: Implementing your own data structure builds a much deeper intuition than just using ArrayList. Sentinel Power: Using a dummy node is a "pro-tip" that eliminates many if (head == null) checks, making the code much cleaner and less error-prone. Index Precision: Off-by-one errors are the biggest challenge in Linked Lists; tracing the "previous" node is the key to success. #DSA #LeetCode #Java #DataStructures #CodingJourney #100DaysOfCode #Day50
To view or add a comment, sign in
-
-
Day 60 of DSA Journey 🚀 Solved Implement Queue using Stacks (LeetCode 232) today. At first glance, it looks like a basic stack problem… but it’s really about understanding how to reverse order efficiently. Key Learnings: Using two stacks to simulate FIFO behavior Lazy transfer: only move elements when needed (not every push) Amortized O(1) operations is the real trick here Approach: push → add to stack1 peek/pop → transfer elements to stack2 only when required Complexity: Time: Amortized O(1) Space: O(n) Small problem, but sharpens thinking around data structure design. #Day60 #DSA #LeetCode #Java #ProblemSolving
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