Day 48 of My 90-Day Coding Challenge Today I solved Merge Intervals, and this one was tricky until I truly visualized what was happening. At first, the logic didn’t click. But once I started thinking in terms of interval overlap on a number line, everything became much clearer. Key concepts I learned today: • Sorting based on starting index using a comparator • Understanding how sorting simplifies complex problems • Merging intervals by tracking the current start and end range The biggest realization: Without sorting, this problem is messy. With sorting, it becomes structured and manageable. Also got hands-on with: • Writing a custom comparator • Using Arrays.sort() effectively for 2D arrays Key takeaway: Some problems feel hard not because of logic, but because you’re not visualizing them correctly. Once the visualization is clear, the solution becomes almost obvious. #90DaysOfCode #DSA #Java #LeetCode #Sorting #ProblemSolving
90-Day Coding Challenge: Solved Merge Intervals with Sorting
More Relevant Posts
-
🚀 𝗗𝗮𝘆 - 48/60 Problem: Rotate Array by One (Right Rotation) 🔍 Learned: To rotate the array by one position to the right, store the last element, shift all elements one step to the right, and place the stored element at the beginning. 😅 Struggles: Initially mixed up left and right rotation logic and tried shifting from left to right, which caused overwriting and wrong results. Also made indexing mistakes like accessing invalid positions. 🧠 Key Learning: Always decide direction first (left vs right) before coding. For right shift, traverse from end to start to avoid overwriting. Store the element that will be lost (last element here) before shifting. 📦 Concepts Used: #Arrays #Traversal #InPlace #LogicBuilding #DSA Direction clarity + correct traversal = clean solution. 🚀 #Java #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 66 of #LeetCode Challenge ✅ Problem Solved: Divide a String Into Groups of Size K 💡 What I learned today: • Learned how to break a string into fixed-size groups • Understood how to handle incomplete groups using a fill character • Practiced building strings step-by-step using loops • Improved clarity on index handling and conditions 🧠 Approach: • Traverse the string one character at a time • Build a group until it reaches size k • Store the group and reset • If the last group is smaller, fill remaining positions with the given character 📊 Key Takeaway: Handling edge cases (like incomplete groups) is very important in problem solving 🔥 Consistency is the key — improving step by step every day! #Day66 #LeetCode #CodingJourney #DSA #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 26/100 Days of #CodeChallenge Today’s problem: Isomorphic Strings (Leetcode 205) This problem helped me understand how to map characters between two strings while maintaining consistency and order. 💡 Key Concept: Two strings are isomorphic if characters in one string can be replaced to get the other string — with: ✔️ One-to-one mapping ✔️ No two characters mapping to the same character ✔️ Order preserved 🧠 What I Learned: How to use mapping (arrays/hashmaps) efficiently Importance of bidirectional checking Handling edge cases like unequal lengths ⚡ Approach: Compare lengths first Track character mappings using arrays Ensure consistency in both directions ⏱️ Complexity Analysis: Time Complexity: O(n) → We traverse the strings once Space Complexity: O(1) → Fixed-size arrays (256 characters) ✅ Successfully solved and understood the logic! Every day is a step closer to mastering problem-solving 💪 #Day26 #100DaysOfCode #Java #DSA #LeetCode #CodingJourney #ProblemSolving #TechLearning
To view or add a comment, sign in
-
-
Day 42/100 – LeetCode Challenge Problem: Top K Frequent Elements Today I worked on the “Top K Frequent Elements” problem, which focuses on identifying the k most frequent elements from an array. I approached this by first using a HashMap to store the frequency of each element. Once the frequencies were calculated, I converted the map into a list of pairs and sorted it based on frequency. From the sorted structure, I extracted the top k elements by selecting from the highest frequency values. This approach keeps the logic straightforward and easy to follow, especially when prioritizing clarity before optimization. While sorting introduces additional overhead, it provides a clean way to rank elements based on frequency. The solution runs in O(n log n) time due to sorting, with O(n) space complexity. This problem reinforced the importance of frequency counting combined with sorting techniques, and how different approaches can be chosen depending on the trade-off between simplicity and efficiency. Forty-two days in. Consistency is now translating into structured thinking. #100DaysOfLeetCode #Java #DSA #Hashing #Sorting #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 37 of My Coding Journey Today, I solved an interesting problem on array manipulation where I learned how to efficiently build a target array using given index positions. Instead of manually handling shifts, I used a loop along with dynamic data structures to simplify insertion and maintain clean logic. This helped me better understand the importance of choosing the right data structure to reduce complexity. 💡 Key takeaway: Using the right approach can turn a complex problem into a simple one. #Day37 #CodingJourney #Java #DSA #ProblemSolving #LeetCode #LearningInPublic
To view or add a comment, sign in
-
-
Day 59 of My 90-Day Coding Challenge Today’s problem was a good reminder that clean thinking beats unnecessary setup. Initially, I approached it by creating a separate search space array (1–9) and building my solution on top of that. But then I stopped and questioned it: - Do I really need this extra structure? Turns out — I didn’t. I optimized the approach by directly using the index as the number, removing the need for any additional array. Key learning: • Not every problem needs extra data structures • Sometimes optimization is about removing what’s unnecessary • Cleaner recursion → better control over the solution #90DaysOfCode #DSA #Java #Recursion #Backtracking #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
Day 8/30 of my #30DaysDSAChallenge 🚀 Solved Problem 70 on LeetCode: Climbing Stairs 🧗♂️ At first glance, it looks simple — but the real learning was in identifying the pattern. This problem is a classic example of how Dynamic Programming works behind the scenes. 💡 Key Insight: To reach step n, you can either come from n-1 or n-2. Which leads to a Fibonacci-like relation: 👉 ways(n) = ways(n-1) + ways(n-2) Instead of using recursion (which is inefficient), I implemented an optimized iterative approach with O(n) time and O(1) space. 📚 What I learned today: Recognizing DP patterns in problems Converting recursion → optimized iteration Importance of space optimization Small steps every day, but getting stronger with problem-solving 💪 #DSA #LeetCode #Java #ProblemSolving #CodingJourney #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Day 8 — Array problems Searching & basic operations Method practice (modular coding) Big shift: Stopped writing everything in one block. Started breaking problems into functions. Less chaos. More structure. Day 9 tomorrow. #LearnInPublic #Java #BuildInPublic
To view or add a comment, sign in
-
📘 DSA Journey — Day 19 Today’s focus: Sliding Window with uniqueness and distance constraints. Problems solved: • Minimum Consecutive Cards to Pick Up (LeetCode 2260) • Substrings of Size Three with Distinct Characters (LeetCode 1876) Concepts used: • Sliding Window / Two-pointer technique • HashMap / Set for tracking duplicates • Window size and distance calculation Key takeaway: In Minimum Consecutive Cards to Pick Up, the goal is to find the smallest subarray containing duplicate elements. A HashMap is used to store the last index of each card. When a duplicate is found, we calculate the distance between indices and update the minimum length. In Substrings of Size Three with Distinct Characters, a fixed-size sliding window (size = 3) is used. We check whether all characters in the window are distinct using a set or frequency array, and count such valid substrings. Both problems highlight how tracking element positions or uniqueness helps efficiently solve problems involving constraints on subarrays or substrings. Continuing to strengthen sliding window patterns and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 16/100 Days of Code Challenge Solved the classic “Sort Colors” problem (LeetCode 75) today! 🎯 🔹 Problem Summary: Given an array containing 0s, 1s, and 2s (representing colors), sort them in-place without using built-in sort. 🔹 Approach Used: Maintained three pointers: low, mid, high Efficiently partitioned the array in a single pass 🔹 Key Learning: ✔️ In-place sorting can be done in O(n) time ✔️ Using pointers smartly avoids extra space 💡 Time Complexity: O(n) 💡 Space Complexity: O(1) 🔹 Code Highlight : Used swapping and pointer movement to organize elements in one traversal. Consistency is the key 🔑 — one step closer to mastering DSA! #Day16 #100DaysOfCode #DSA #Java #CodingChallenge #LeetCode #ProblemSolving #TechJourney
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