Day 19 Of #100DaysOfCode: #DSA: Solve leetcode problem with Merge Intervals Pattern - Insert Intervals(medium 57) Approach: - Sort the array by start time - create a temp vector/array - now iterate over intervals and check for each interval if its start time is greater then the newInterval start time if it is then add newInterval into the temp else add curr interval - now merge the intervals that are stored in temp vector/array Time Complexity: O(n logn) Space Complexity: O(n) #Coding #LearnInPublic #CodingJourney
Merge Intervals Pattern Solution with LeetCode
More Relevant Posts
-
Day 23 of #100DaysOfCode: #DSA: Stack: 1. Simple Stack 2. Monotonic stack: Stores items in sorted order(strictly increasing/decreasing) 3. Greedy Stack: pop/push based on greedy decisions to build an optimal result. Leetcode Problem: - Remove All Adjacent Duplicates(1047) approach: - use stack - assume first item is unique and add it to the stack - now iterate over the string - if stack top == current char then pop (it's adjacent and duplicate remove them) - else push current char - build final string from the stack and return it Time Complexity: O(n) Space Complexity: O(n) #Coding #CodingJourney
To view or add a comment, sign in
-
-
30 Days of DSA Leetcode Problems– Day 12 Today’s problem: Daily Temperatures Approach Used – Monotonic Stack To solve this efficiently: Traverse the temperature array Use a stack to store indices of unresolved days While the current temperature is higher than the temperature at the index on top of the stack: Pop the index Calculate the number of days waited Push the current index into the stack This ensures each element is processed efficiently. Time Complexity: O(n) Space Complexity: O(n) Day 12/30 #DSA #LeetCode #Stack #Coding #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 3/100 – LeetCode DSA Challenge Problem: Fibonacci Number (#509) 🎯 Goal: Calculate the nth Fibonacci number. 💡 Key Insight: Recursive approach is simple but can be slow due to repeated calculations. Iterative approach with a loop is faster, O(n) O(n) time and O(1) O(1) space. For large n, think about dynamic programming or matrix exponentiation. One step closer to mastering patterns in problems 💪 #100DaysOfCode #LeetCode #DSA #ProblemSolving #CodingChallenge
To view or add a comment, sign in
-
-
🚀 Day 10/60 — LeetCode Discipline Problem Solved: Longest Palindromic Substring (Revision) Difficulty: Medium Today’s session was dedicated to revisiting one of the most elegant string problems — finding the longest palindromic substring. This problem goes beyond basic traversal and demands a deeper understanding of symmetry, center expansion, and efficient substring handling. During this revision, the focus was on strengthening pattern recognition and writing an optimized solution with clean logic. 💡 Focus Areas: • Deepened understanding of palindrome symmetry • Strengthened string transformation and center-based reasoning • Practiced handling odd vs even length palindromes • Focused on improving time complexity awareness • Emphasized clean and maintainable implementation ⚡ Performance Highlight: Achieved ~97% runtime efficiency on submission. Consistent revision of classical problems is steadily improving my pattern recognition and algorithmic confidence. The journey continues with sharper intuition and stronger fundamentals each day. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #Strings #Palindrome #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #TechCareers #Programming #Developers #CodingLife
To view or add a comment, sign in
-
-
Getting code to a running state is often the first hurdle. Even if imperfect, achieving a functional baseline allows for iteration and debugging. The mechanics are working, which means any issues can be addressed within the existing framework. The key is to get it running, then refine. Problems identified in a working system are far easier to solve. #SoftwareDevelopment #ProblemSolving #TechTips #Coding
To view or add a comment, sign in
-
#Day42 Of #100DaysOfCode: #DSA: solve leetcode problem - Search a 2D Matrix II simple approach: - start from matrix[last_row][first_col] - check if matrix[row][col] > target then go up means row--; - else if matrix[row][col] < target then go right means col++; - else means matrix[row][col] == target -> return true; - int the last return false it will only run when the loop does't return Time: O(m + n) space: O(1) #DSA #Coding #Daily #Leetcode #CodingJourney #Learning
To view or add a comment, sign in
-
-
THE PAIN: Mismatched brackets plague code. Unclosed parentheses and stray braces lead to confusing errors that steal precious debugging time. THE INSIGHT: This happens because keeping track of nested structures linearly is hard. We naturally think about opening and closing pairs. THE FIX: Use a stack. When you see an opening bracket, push it onto the stack. When you see a closing bracket, check if the top of the stack is its matching opener. If it is, pop it. If not, or if the stack is empty, you've found an error. At the end, if the stack is empty, all brackets are matched. THE OUTCOME: Fewer bugs. More predictable code. Faster development cycles. #coding #programming #softwareengineering #datastructures #algorithms
To view or add a comment, sign in
-
-
Day 28 of #100DaysOfCode: #DSA: Solve leetcode problem - Longest Palindrome(409) A palindrome string can be even/odd length so if the frequencies of letters are: 1. Even - we can use all of them to create palindrome string 2. Odd: - we can use frequency - 1 witch becomes even - we can leave one character for the middle approach: - hashmap to track freq of letters - iterate to the string - if freq is even just add to result - if freq is odd then add (freq - 1) to result - now in the last check - if hashmap contains only even freq return result - else return (result + 1) for middle character #Coding #Learing #CodingJourney
To view or add a comment, sign in
-
-
20 of #100DaysOfCode Solved LeetCode 438 – Find All Anagrams in a String using the Sliding Window Technique. 🔹 Approach (Optimal – Sliding Window): Used frequency arrays and a fixed window of size k to track character counts efficiently. Time Complexity: O(n) Space Complexity: O(1) 💡 Key Learning: Sliding Window helps reduce repeated computation when dealing with contiguous subarrays/substrings. 📌 Always look for patterns where a fixed-size window can optimize brute force solutions. #leetcode #coding #cpp #datastructures #algorithms #programming #softwareengineering #slidingwindow #dsa #100DaysOfCode
To view or add a comment, sign in
-
-
Day 69 – Next Greater Element II: Circular Arrays and Monotonic Stacks 🔄📈 Today's challenge extended the next greater element concept to a circular array where elements can look ahead and wrap around to find their successor, pushing both stack technique and circular reasoning to new heights. 🔄 Next Greater Element II I approached this problem by simulating the circular nature through array doubling conceptually, without physically creating extra space. By iterating twice through the array (2n iterations) and using a monotonic decreasing stack that stored indices, I processed each element modulo n. For each new element, I popped smaller indices from the stack and recorded the current element as their next greater value. After two full passes, all elements had either found their greater successor or remained -1. This elegant approach achieved O(n) time with O(n) space. #LeetCode #Coding #Algorithms #DataStructures #MonotonicStack #CircularArray #NextGreaterElement #Stack #ProblemSolving #SoftwareEngineering #Programming #100DaysOfCode
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