🚀 Day 24/90 – Solved LeetCode 1288: Remove Covered Intervals Continuing my DSA consistency journey, today I worked on an Interval Pattern problem: Remove Covered Intervals. 💡 Problem Insight An interval [a, b] is considered covered if another interval [c, d] exists such that: c ≤ a and b ≤ d The challenge is to remove all such covered intervals and return the number of remaining intervals. ⚙️ Approach • Step 1 – Sorting Strategy Sort intervals by start time ascending and end time descending. This ensures that larger intervals appear first when the start point is the same. • Step 2 – Track Maximum End Maintain a variable maxEnd representing the farthest end seen so far. • Step 3 – Identify Valid Intervals If the current interval’s end is greater than maxEnd, it means the interval is not covered, so we update maxEnd and count it. 📊 Performance Runtime: 6 ms Faster than 90% of submissions 📚 Key Takeaway A well-designed sorting strategy can significantly simplify interval problems and reduce unnecessary comparisons. Staying consistent and learning new problem-solving patterns every day. #DSA #LeetCode #Java #Algorithms #ProblemSolving #SoftwareEngineering #CodingJourney
Remove Covered Intervals LeetCode Solution
More Relevant Posts
-
🚀 Day 13/100 – LeetCode DSA Challenge 🔹 Problem Solved: 238. Product of Array Except Self Today’s problem was a great exercise in array manipulation and optimization. 📌 Problem Summary: Given an array nums, return a new array where each element is the product of all elements except itself. 📊 Example: Input: [1,2,3,4] Output: [24,12,8,6] 💡 What I Learned: How to handle edge cases like zeros in an array Importance of time complexity O(n) Why some solutions (like division) are not always valid Concept of prefix & suffix products (optimal approach) ⚠️ Challenge: Cannot use division Must solve in linear time 🧠 My Approach: First tried using total product and division Faced issues with zero values (division by zero error) Improved the logic by handling zero cases carefully 🔥 Key Insight: If there is: More than 1 zero → all outputs = 0 Exactly 1 zero → only that index gets product No zero → normal calculation works 📈 Next Goal: Learn and implement the optimal solution without division (prefix + suffix method) #Day13 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney #ProblemSolving #FutureDeveloper
To view or add a comment, sign in
-
-
📅 Day 17/100 – LeetCode Challenge 🔹 Problem: 268. Missing Number Today I solved an easy but important array problem where I had to find the missing number from a given range [0, n]. 💡 My Approach: Calculated the expected sum of numbers from 0 to n using formula Calculated the actual sum of elements in the array Subtracted both to find the missing number 🧠 Code Logic: Expected Sum = n * (n + 1) / 2 Missing Number = Expected Sum - Actual Sum 📌 What I Learned: How to use mathematical formulas to optimize problems Avoid unnecessary loops or sorting Improved understanding of array traversal Learned an efficient O(n) solution 🚀 Key Takeaway: Using math-based logic can simplify problems and make solutions faster and cleaner. #Day17 #100DaysOfCode #Java #LeetCode #DSA #Learning
To view or add a comment, sign in
-
-
🚀 Day 27/100 – LeetCode DSA Challenge 📌 Problem Solved: Find All Numbers Disappeared in an Array Today’s problem focused on identifying missing numbers from an array where elements are in the range [1, n]. 🔍 Approach I Used (Easy Method): Created a boolean array to track visited numbers Marked each number as present Iterated from 1 to n to find missing elements 💡 Key Concepts Learned: How to use index-based mapping for arrays Importance of range constraints [1, n] Difference between brute force vs optimized approach Using extra space to simplify logic 🧠 What I Understood Today: If a problem says numbers are in range [1, n], we can directly map values to indices Tracking frequency or presence is a powerful technique Writing clean and simple logic first is more important than jumping to optimization 🔥 Next Step: I will try the optimized approach (O(1) space) using index marking (negative marking technique) 📈 Improving step by step in DSA — consistency is the key! #Day27 #LeetCode #DSA #100DaysOfCode #CodingJourney #PlacementsPreparation #Java
To view or add a comment, sign in
-
-
Day 77 - LeetCode Journey Solved LeetCode 82: Remove Duplicates from Sorted List II (Medium) today — a more advanced version of the duplicate removal problem. Unlike the basic version, here we need to remove all nodes that have duplicates, leaving only distinct values. 💡 Core Idea: Use a dummy node + two pointers approach. • A dummy node helps handle edge cases (like duplicates at the head) • Use prev to track the last confirmed unique node • Use curr to traverse the list When duplicates are found: → Skip all nodes with that value → Connect prev.next to the next distinct node If no duplicate: → Simply move prev forward ⚡ Key Learning Points: • Importance of a dummy node in linked list problems • Handling edge cases at the head • Removing elements completely (not just skipping extras) • Clean pointer manipulation with O(n) time and O(1) space This problem highlights the difference between: Keeping one copy (Easy version) Removing all duplicates (Medium version) That small change makes the logic significantly more interesting. ✅ Stronger understanding of pointer control ✅ Better handling of edge cases ✅ Improved problem-solving depth in linked lists These variations are where real learning happens 🚀 #LeetCode #DSA #Java #LinkedList #Algorithms #ProblemSolving #CodingJourney #Consistency #100DaysOfCode #InterviewPreparation #DeveloperGrowth #KeepCoding
To view or add a comment, sign in
-
-
🚀 LeetCode Problem Solved: Keys and Rooms (Day 43 of DSA Journey) Today, I tackled LeetCode 841 – Keys and Rooms, a great problem to strengthen understanding of graph traversal (DFS/BFS). 🔐 Problem Summary: We are given n rooms where only room 0 is initially unlocked. Each room may contain keys to other rooms. The goal is to determine whether we can visit all rooms using the available keys. 💡 Approach: Treat rooms as nodes and keys as edges Start traversal from room 0 Use DFS (Stack) or BFS (Queue) Track visited rooms to avoid repetition Finally, check if all rooms were visited 🧠 Key Insight: This problem is a classic example of checking whether a graph is fully reachable from a source node. ⏱️ Complexity: Time: O(n + e) Space: O(n) ✅ Outcome: Successfully implemented using DFS & BFS approaches. #LeetCode #DSA #Java #GraphTraversal #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 25/100 – LeetCode DSA Challenge ✅ Problem Solved: Third Maximum Number Today’s problem focused on finding the third distinct maximum number in an array. If it doesn’t exist, we return the maximum number. 🔍 Key Learnings: • Importance of handling distinct values (duplicates ignored) • Efficient tracking of top 3 values without sorting • Achieving O(n) time complexity using a single pass • Better understanding of edge cases like negative numbers 💡 Approach: Instead of sorting (O(n log n)), I used three variables to track the first, second, and third maximum values while iterating through the array once. 📌 Example: Input: [2,2,3,1] Output: 1 🎯 This problem improved my thinking on optimization and clean logic building. #Day25 #100DaysOfCode #DSA #LeetCode #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
📘 DSA Journey — Day 11 Today’s focus: Sliding Window with distinct element constraints. Problem solved: • Subarrays with K Different Integers (LeetCode 992) Concepts used: • Sliding Window / Two-pointer technique • Frequency tracking using HashMap • Counting subarrays using window expansion Key takeaway: The goal of this problem is to count the number of subarrays that contain exactly K distinct integers. A useful trick here is to break the problem into two parts: Subarrays with exactly K distinct = Subarrays with at most K distinct − Subarrays with at most (K−1) distinct Using a sliding window, we maintain a window that contains at most K distinct elements. A frequency map keeps track of how many times each element appears in the current window. As the window expands, if the number of distinct elements exceeds K, we shrink the window from the left until the condition is satisfied again. At each step, the number of valid subarrays ending at the current index can be counted efficiently, allowing the entire problem to be solved in O(n) time. Continuing to strengthen pattern recognition and consistency in solving DSA problems. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
Today I solved LeetCode 100 – Same Tree. 🧩 Problem Summary: Given the roots of two binary trees p and q, check whether they are identical (same tree). Two trees are considered the same if: They are structurally identical. Corresponding nodes have the same values. 💡 Key Concepts Used: Binary Trees Recursion Depth First Search (DFS) Tree comparison 🧠 Approach: If both nodes are null, return true. If one is null and the other is not, return false. If the values of both nodes are different, return false. Recursively compare: Left subtree of both trees. Right subtree of both trees. If all checks pass, the trees are identical. 📚 What I Learned: How to compare two binary trees recursively. Handling base cases carefully in recursion. Strengthening DFS concepts in tree problems. Building a strong foundation for advanced tree problems. Consistency in practice leads to mastery . Learning something new every day #LeetCode #DSA #BinaryTree #SameTree #DFS #Recursion #Java #CodingJourney #ProblemSolving #100DaysOfCode #TechGrowth
To view or add a comment, sign in
-
-
Today I solved LeetCode 104 – Maximum Depth of Binary Tree. 🧩 Problem Summary: Given the root of a binary tree, return its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 💡 Key Concepts Used: Binary Trees Recursion Depth First Search (DFS) Tree traversal 🧠 Approach: Use DFS (recursion) to explore the tree. For each node: Recursively calculate the depth of the left subtree. Recursively calculate the depth of the right subtree. The depth of the current node = 1 + max(left depth, right depth) Base case: if node is null, return 0. ⏱ Time Complexity: O(N) — Each node is visited once. 📚 What I Learned: Understanding tree depth calculation. Strengthening recursion and DFS concepts. Difference between maximum depth vs minimum depth. Building intuition for tree-based problems. Strong fundamentals in trees make advanced problems easier Consistency is the key to improvement #LeetCode #DSA #BinaryTree #MaximumDepth #DFS #Recursion #Java #CodingJourney #ProblemSolving #100DaysOfCode #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 69 — LeetCode Practice 🚀 Today’s focus was on string manipulation and careful indexing. ✅ Problem solved today: 🔹 Find Common Characters 💡 Key learnings from today: • Understood how to find common characters across multiple strings • Learned the importance of character frequency counting • Practiced handling nested loops efficiently • Realized how small mistakes in indexing can affect the entire logic • Improved attention to detail while working with strings Initially, I made a mistake by using the wrong variable inside charAt(). This caused incorrect indexing, which can either lead to wrong output or even StringIndexOutOfBoundsException. After fixing it, the logic worked perfectly by correctly comparing characters and tracking their minimum frequency across all words. This problem reinforced an important lesson: Sometimes errors are not in logic — but in small details like indexing and variable usage. Accuracy matters as much as logic. Step by step, getting better 💪 On to Day 70 🚀 #Day69 #DSA #LeetCode #ProblemSolving #Java #CodingJourney #Consistency #FutureEngineer
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