🧩 Day 78 of #100DaysOfCode Challenge 🧩 📘 LeetCode 56 — Merge Intervals Topic: Arrays & Sorting Today’s problem was about merging overlapping intervals — a real test of logical thinking and array manipulation skills! 💡 Problem Summary: Given multiple intervals, the goal is to merge all overlapping ones and return a list of non-overlapping intervals that cover all ranges in the input. ⚙️ Approach (Brute + Optimized): 1️⃣ Sort all intervals based on their start value. 2️⃣ Compare the current interval with the previous one: If they overlap, merge them by updating the end time. If not, add the previous interval to the result. 3️⃣ Continue until all intervals are processed. 🧠 Key Learning: Sorting simplifies overlapping detection. Interval-based problems help strengthen array and logic handling. Real-world application: scheduling problems and timeline merging! ✨ Each problem is another step toward mastering patterns in DSA. #Day78 #LeetCode #100DaysOfCode #Java #DSA #ProblemSolving #WomenInTech #CodingJourney #Arrays #Sorting
Merging Intervals with LeetCode and Java
More Relevant Posts
-
🔹 Day 40 – LeetCode Practice Problem: Find Greatest Common Divisor of Array (LeetCode #1979) 📌 Problem Statement: Given an integer array nums, find the greatest common divisor (GCD) of the smallest and largest numbers in the array. ✅ My Approach (Java): 1. Find the minimum and maximum elements in the array. 2. Starting from the smaller number and going downwards, check for the highest integer that divides both min and max. 3. Return that integer as the GCD. 📊 Complexity: Time Complexity: O(n + min(a, b)) Space Complexity: O(1) ⚡ Submission Results: Accepted ✅ Runtime: 0 ms (Beats 100%) 🚀 Memory: 43.41 MB (Beats 41.55%) 💡 Reflection: This problem shows how basic math logic and loop optimization can lead to extremely efficient solutions. A simple and powerful way to practice number theory in coding! #LeetCode #ProblemSolving #Java #DSA #CodingPractice #Learning
To view or add a comment, sign in
-
-
📌 Day 18/100 - Valid Palindrome (LeetCode 125) 🔹 Problem: Determine whether a string reads the same forward and backward, ignoring case and non-alphanumeric characters. 🔹 Approach: Implemented a two-pointer technique. Skipped all non-alphanumeric characters. Compared characters from both ends in lowercase. Returned true if all matched, otherwise false. 🔹 Key Learning: Two-pointer method keeps logic clean and efficient. Character handling is key when data isn’t uniform. Time complexity: O(n), Space complexity: O(1). Sometimes, solving elegantly is better than solving fast. ✨ #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney
To view or add a comment, sign in
-
-
🧮 Day 30 of My #100DaysOfLeetCode Challenge ✅ Problem: Find Target Indices After Sorting Array 🧩 Difficulty: Easy 📂 Category: Array / Counting ⚡ Runtime: 0 ms (Beats 100%) 💾 Memory: 44.54 MB 🔹 Approach: Instead of sorting, I used counting logic to find the number of elements smaller than the target (lessThan) and the count of target elements (count). The resulting indices are then [lessThan, lessThan + 1, ..., lessThan + count - 1]. This avoids unnecessary sorting and keeps the solution O(n). 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) ✨ Learnings: How counting-based reasoning can replace sorting for index-based problems. Focused on optimization and problem pattern recognition. 📈 Progress: Day 30 ✅ | 70 days remaining 🚀 💭 “Optimization is not about doing more — it’s about doing smarter.” #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #CodingChallenge #Consistency
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟏𝟒 of #50DaysOfDSA 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝟏𝟔𝟏𝟏. 𝐌𝐢𝐧𝐢𝐦𝐮𝐦 𝐎𝐧𝐞 𝐁𝐢𝐭 𝐎𝐩𝐞𝐫𝐚𝐭𝐢𝐨𝐧𝐬 𝐭𝐨 𝐌𝐚𝐤𝐞 𝐈𝐧𝐭𝐞𝐠𝐞𝐫𝐬 𝐙𝐞𝐫𝐨 (𝐇𝐚𝐫𝐝) 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤 : https://lnkd.in/g9NsEW8F 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 𝐋𝐢𝐧𝐤 : https://lnkd.in/gKZGpX2B Today’s problem was a real brain-teaser that beautifully connects 𝐛𝐢𝐭 𝐦𝐚𝐧𝐢𝐩𝐮𝐥𝐚𝐭𝐢𝐨𝐧 with 𝐆𝐫𝐚𝐲 𝐜𝐨𝐝𝐞 𝐥𝐨𝐠𝐢𝐜 𝐓𝐡𝐞 𝐜𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞: Transform an integer n → 0 using minimum operations, where each operation allows you to flip certain bits based on specific rules. At first, it looks like a simulation problem... but the real trick lies in understanding how Gray codes work — where consecutive numbers differ by exactly one bit. 𝐈𝐧𝐭𝐮𝐢𝐭𝐢𝐨𝐧: We keep 𝐗𝐎𝐑𝐢𝐧𝐠 𝐧 with its 𝐫𝐢𝐠𝐡𝐭-𝐬𝐡𝐢𝐟𝐭𝐞𝐝 𝐯𝐚𝐥𝐮𝐞 until it becomes 0 , this effectively computes the minimal number of bit flips required. #LeetCode #Java #BitManipulation #CodingChallenge #DSA #ProblemSolving #DeveloperJourney #CodeNewbie #50DaysOfCode #WomenInTech #LearningEveryday
To view or add a comment, sign in
-
-
📌 Day 4/100 - Minimum Size Subarray Sum (LeetCode 209) 🔹 Problem: Given an array of positive integers and a target value, find the minimal length of a contiguous subarray whose sum is greater than or equal to the target. If there’s no such subarray, return 0. 🔹 Approach: Used the Sliding Window technique for an optimized solution: Initialize two pointers (low, high) and a running sum. Expand the window by moving high until the sum ≥ target. Once valid, shrink the window from the left to find the smallest subarray. Keep updating the minimum length throughout. This reduced the time complexity from O(n²) (brute force) to O(n). 🔹 Key Learning: Sliding Window is ideal for problems with contiguous subarrays. Optimization often comes from adjusting the window efficiently. Each problem strengthens logical flow and pattern recognition. Another step forward in mastering DSA and problem-solving consistency! ⚡ #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingChallenge #SlidingWindow
To view or add a comment, sign in
-
-
🌳 Day 36/100 ✅ Preorder Traversal of Binary Tree Today I solved the Preorder Traversal problem using recursion. In this traversal method, the order of visiting nodes is simple yet powerful: 👉 Root → Left → Right This problem helped me understand how recursion can naturally handle tree structures by breaking the problem into smaller subproblems. At each recursive call, we visit the root node first, then move to the left subtree, and finally to the right subtree — making the traversal flow smooth and logical. 💡 Key Takeaways: Preorder traversal always starts from the root. Recursion simplifies complex tree navigation into cleaner and readable logic. Visualizing the function call stack helps to truly understand the flow of recursion. Every day, I’m realizing how recursion is not just a coding tool — it’s a way to think step-by-step through structured problems. 🌱 #Day36 #DSA #CodingJourney #BinaryTree #PreorderTraversal #Recursion #ProblemSolving #LearningEveryday #100DaysOfCode #Java
To view or add a comment, sign in
-
-
🚀 #DSAinJava #Day82 #300DayChallenge Another step forward in the #TUFWinterArc by @takeUforward! ⚡ Today was all about mastering Array Manipulation & Sorting Techniques — pushing boundaries with smart merging and mathematical insights. 💪 🧠 Topics & Problems Covered: 1️⃣ Merge Overlapping Subintervals 2️⃣ Merge Two Sorted Arrays Without Extra Space 3️⃣ Find the Repeating and Missing Number 💡 Key Learnings: 🔹 Learned how to efficiently merge overlapping intervals using sorting and linear traversal (O(n log n) ➡️ O(n)). 🔹 Explored in-place merging strategies for sorted arrays — minimizing space usage while maintaining order. 🔹 Applied mathematical and XOR-based reasoning to identify missing and repeating numbers without extra memory. 🔹 Reinforced the importance of clean implementation and careful edge-case handling in array transformations. ⚡ Mindset Upgrade: Each challenge reminded me that — ✅ Simplicity and optimization often go hand-in-hand ✅ Space-efficient logic is just as important as time optimization ✅ Patience + Precision = Progress 📂 All Solutions (Code + Notes): 👉 https://lnkd.in/deeXep9Q #TUFWinterArc #TakeUForward #Java #DSA #CodingJourney #ProblemSolving #Arrays #InterviewPreparation #LeetCode #CodeEveryday #ConsistencyWins
To view or add a comment, sign in
-
-
🌟 Day 63 of 100 Days of LeetCode 🌟 Today’s challenge: LeetCode 101 – Symmetric Tree 🔁 🧩 Problem Summary: Given the root of a binary tree, determine whether it’s a mirror of itself (i.e., symmetric around its center). 🌲✨ 💡 Key Takeaways: 🔹 Strengthened understanding of recursion in binary trees. 🔹 Learned how to compare mirror nodes (left ↔ right). 🔹 Realized that symmetry problems are perfect practice for recursive thinking and structural comparison. 🧠 Approach: 1️⃣ The tree is symmetric if its left and right subtrees are mirror images. 2️⃣ Use a helper function to compare: left.val == right.val left.left == right.right and left.right == right.left 3️⃣ Handle null checks carefully to avoid exceptions. 🔍 This problem beautifully shows how mirror logic + recursion can simplify complex tree checks! #LeetCode #100DaysOfCode #Java #DSA #BinaryTree #ProblemSolving #CodingJourney #Recursion #SymmetricTree
To view or add a comment, sign in
-
-
🚀 Day 54 of My #100DaysOfLeetCode Challenge 🚀 Today I worked on a problem related to making parentheses valid — a classic stack-based problem that tests your understanding of balanced brackets and edge cases. 💡 Problem: Given a string containing only '(' and ')', determine the minimum number of parentheses that must be added to make the string valid. 🧠 Concepts Used: Stack data structure String traversal Counting unmatched parentheses 🧩 Approach: Traverse through the string character by character. Use a stack to track unmatched '('. When encountering ')', pop from the stack if possible, else increment the counter. Finally, the total unmatched parentheses = stack size + counter. #100DaysOfCode #LeetCode #Java #ProblemSolving #CodingJourney #DSA #WomenInTech #TechLearning #CodeNewbie
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