🧩 DSA Breakdown: Insert Interval One of those problems that looks scary at first, but once you see the pattern — it clicks instantly. The problem: Given a sorted list of non-overlapping intervals, insert a new interval and merge if needed. The trick? Just think in 3 phases: 1️⃣ Add all intervals that END before the new one starts → no overlap, safe to add 2️⃣ MERGE all intervals that overlap → keep expanding the new interval's boundaries 3️⃣ Add everything remaining → they start after the new interval ends ✅ Time: O(n) — single pass ✅ Space: O(n) Currently grinding DSA one problem at a time 💪 If you're on the same journey, let's connect! #DSA #CodingInterview #Python #LeetCode #Programming #100DaysOfCode
Insert Interval into Sorted List with Merge
More Relevant Posts
-
Hello everybody, and welcome to this second personal project of 'Learning Python with me'. Today, I have been asked to create a commission calculator for a friend, and we will use Python to make a simple calculator that shows the percentage commission. What do we need? - Name - Income - Commission result Throughout this project, I realized that I needed to convert strings into integers, since the final result had to be a number. I also learned how to use variables in mathematical operations and print them as a final result. Here is how it looks. I hope you enjoy it! :) #Python #PythonProject #SideProject #fyp #Programming #OpsDeveloper
To view or add a comment, sign in
-
Today I learned about an interesting problem: Happy Number 👉 A number is called Happy if: Replace the number by the sum of the squares of its digits Repeat the process If it becomes 1, it's a Happy Number ✅ If it loops endlessly, it's NOT ❌ 💡 Example: 19 → 1² + 9² = 82 82 → 8² + 2² = 68 68 → 6² + 8² = 100 100 → 1² + 0² + 0² = 1 ✅ 🧠 Key Learning: Cycle detection is important here We can use a set or fast & slow pointers to detect loops 💻 This problem helped me understand: ✔ Number manipulation ✔ Loop detection logic ✔ Problem-solving approach Consistency is the key 🔑 — learning something new every day! 👉 Have you solved this problem using a different approach? #DSA #Python #CodingJourney #100DaysOfCode #ProblemSolving #SoftwareDeveloper
To view or add a comment, sign in
-
🚀 Day 5 — DSA with Python Solved the classic “Product of Array Except Self” problem today. This one introduced me to an important concept: 👉 Precomputation (Prefix & Suffix Pattern) Instead of recalculating products again and again, I learned how to: • Store prefix products (left side) • Store suffix products (right side) • Combine them to get the result efficiently 💡 Key Learning: Optimizing brute-force solutions using precomputation can significantly reduce time complexity. ⚡ What challenged me: Understanding how to manage two passes (left → right and right → left) without using extra space initially felt confusing — but breaking it step by step helped. 📈 Growth Insight: DSA is less about memorizing solutions and more about recognizing patterns like this one. On to Day 6 🔥 #DSA #Python #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
📘 Python Learning – Day 3 Highlights 🐍 Today’s class was all about Strings & Conditional Logic — very practical and fun! 🔹 String Methods: Used functions like lower(), upper(), strip(), replace(), find(), count(), and split() 🔹 String Formatting: Learned modern and clean way using f-strings 🔹 Conditional Statements: if, elif, else to make decisions in programs 🔹 Ternary Operator: Short and smart way to write conditions in one line 🔹 Practice Programs: ✔ Grade calculation system ✔ Palindrome checker ✔ Vowel counter 💡 Example: text == text[::-1] → checks palindrome Learning how to think logically with code step by step 🚀 #Python #Programming #Coding #LearningJourney #Beginner #TechSkills
To view or add a comment, sign in
-
-
Day 22 of #LeetCode Challenge – Mastering Binary Search Ever searched for a word in a dictionary? You don’t check page by page… you jump to the middle. 👉 That’s exactly how Binary Search works! 💡 Problem Solved: Binary Search 🔍 Given a sorted array, find the index of a target element. ⏱️ Required Time Complexity: O(log n) ⚡ Instead of scanning every element, Binary Search cuts the search space in half every step, making it super efficient for large datasets #LeetCode #BinarySearch #DSA #CodingJourney #150DaysOfCode #Programming #Python #Tech
To view or add a comment, sign in
-
-
Check out my handbook "Fine-tuning Llama 3.2 model with LoRA" ❤️ If you are looking to fine-tune large language models efficiently, I just put together a comprehensive handbook breaking down the entire process using the Llama 3.2 - 1 billion parameter model and parameter-efficient LoRA technique! 🚀 #programming #coding #python
To view or add a comment, sign in
-
Day 13/100 – Understanding Before Solving Today’s problem: Reverse String At first glance, it looks simple—but the real goal is to understand how to solve it efficiently. The challenge is to reverse the string in-place, meaning without using extra memory. Approach Explained: We use the two-pointer technique: One pointer starts from the beginning One from the end Swap characters and move inward This avoids creating a new array and keeps the solution optimal. Time Complexity: O(n) Space Complexity: O(1) Key Learning: Writing code is important, but understanding why it works is what truly builds strong problem-solving skills. One step closer to mastering DSA. #100DaysOfCode #DSA #Learning #ProblemSolving #Python #LeetCode #GrowthMindset
To view or add a comment, sign in
-
-
📌 Problem: Sum of Digits in Base K 💡 Approach: Convert the given number into base k by repeatedly dividing it by k. At each step, take the remainder (n % k) which represents the digit in base k, and add it to the sum. Continue until the number becomes zero. ⚙️ Key Insight: Base conversion using division and remainder No need to explicitly store the converted number ⏱️ Time Complexity: O(logₖ n) 📦 Space Complexity: O(1) 📚 What I learned: Efficient base conversion technique Working with number systems in coding problems #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #Math #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
🚀 Day 16 of #100DaysOfCoding Today I worked on pattern problems using Python, focusing on nested loops and condition logic. 🔹 Built a hollow square pattern using while loops 🔹 Strengthened understanding of loop control (i, j iterations) 🔹 Learned how to apply conditions for borders vs inner spaces 🔹 Practiced dry run techniques to debug and visualize code execution 💡 Key Learning: Breaking a problem into rows and columns makes pattern questions much easier to solve. The real trick is identifying where to print values and where to skip. Consistency is slowly turning confusion into clarity 💪 #Python #Coding #DSA #Programming #LearningJourney #Consistency n = int(input()) i = 1 while(i <= n): j = 1 while(j <= n): if(i == 1 or i == n): print("*", end="") elif(j == 1 or j == n): print("*", end="") else: print(" ", end="") j += 1 print("") i += 1
To view or add a comment, sign in
-
-
Day 111 Backtracking is starting to feel consistent now. #Day111 🧩 39. Combination Sum How today went: • Used backtracking with index i • Two choices: → stay at i (reuse the same element) → move to i + 1 (try next element) • Track the current total • If total == target → add result • If total > target → stop that path What I realized: This problem is about: → controlling index movement → managing the running total Same pattern, different control. Revision is making it clearer. #LeetCode #DSA #Python #Backtracking #Recursion #LearningInPublic #Consistency
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