🚀 Day 39 / 100 – Problem Solving Challenge Today I worked on the Minimum Window Substring problem — a classic and highly important interview question in string and sliding window concepts. 📌 Problem Statement: Given two strings s and t, the task is to find the smallest substring of s such that it contains all characters of t (including duplicates). If no such substring exists, return an empty string. 💡 Approach Used: Built a frequency map for string t Used a brute-force approach to check every possible substring of s For each substring, maintained a frequency map and validated if it satisfies all characters of t Updated the result whenever a smaller valid window was found ⚙️ Time Complexity: O(n² × k) (inefficient for large inputs, but good for understanding the concept) 📚 Key Learnings: Importance of frequency maps in substring problems How brute-force window expansion works Understanding why optimized sliding window is needed for real-world efficiency #100DaysOfCode #ProblemSolving #Python #CodingJourney #Algorithms #SlidingWindow #LearningByDoing
Minimum Window Substring Problem Solution
More Relevant Posts
-
🚀 Day 84 of #100DaysOfCode ✅ Solved: Rotate Image (LeetCode 48) Today’s problem was all about rotating an n × n matrix by 90° clockwise — in-place (without using extra space). 💡 Key Insight: Instead of creating a new matrix, we can break the problem into two smart steps: 1️⃣ Transpose the matrix (swap rows with columns) 2️⃣ Reverse each row This transforms the matrix exactly as required — clean and efficient! 🧠 Why this works: - Transpose flips the matrix across its diagonal - Reversing rows completes the 90° clockwise rotation ⚡ Complexity: - Time: O(n²) - Space: O(1) (in-place) 📌 Takeaway: Many matrix problems become easier when broken into transformations like transpose + reverse. Recognizing these patterns is a game-changer in coding interviews. #LeetCode #DataStructures #CodingJourney #Python #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
📌 Problem: 1679. Max Number of K-Sum Pairs 💡 Approach: First, sort the array to efficiently apply the two-pointer technique. Initialize two pointers: one at the start (left) and one at the end (right). If the sum equals k, we found a valid pair → increment count and move both pointers If the sum is greater than k, move the right pointer to reduce the sum If the sum is smaller than k, move the left pointer to increase the sum Continue until both pointers meet. ⚙️ Key Insight: Sorting enables efficient pair finding Two-pointer approach avoids checking all pairs (O(n²)) Greedy selection ensures maximum number of operations ⏱️ Time Complexity: O(n log n) (due to sorting) 📦 Space Complexity: O(1) (ignoring sorting space) 📚 What I learned: Two-pointer technique on sorted arrays Optimizing pair problems from brute force to efficient solutions #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #TwoPointers #Greedy #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
Day 12/30 🔹 Problem: Print multiplication table of a number 🔹 What I focused on today: Using loops to repeat calculations efficiently 🔹 My Thinking Process: Take a number as input Use a loop from 1 to 10 Multiply the number with each value Print the result step by step 👉 Repetition becomes easy with loops 🔹 Inputs I used: A number 🔹 Code: num = int(input("Enter a number: ")) for i in range(1, 11): result = num * i print(num, "x", i, "=", result) 🔹 Example: Input: 5 Output: 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 ... 5 x 10 = 50 🔹 Key Takeaway: Loops help automate repetitive tasks, making code more efficient and scalable #Day12 #Python #30DaysOfCode #LearningInPublic #DataAnalytics #ProblemSolving
To view or add a comment, sign in
-
-
Automation Case 1: Well Collision Check I’m starting a short PDF series of practical automation cases from my reservoir-engineering work: Python and VBA tools built to reduce routine tasks, improve QC, and make workflows more repeatable. Some of them come from my Python coding challenge I completed in December. You can find more under #30dayPyCodingChallenge tag. Today's one is a well collision check tool. I automated this workflow into a pairwise collision screening web-app that: 🔹scans all wells below a selected MD cutoff, 🔹flags dangerous close approaches, 🔹exports a distance matrix and flagged pairs table, 🔹gives a quick visual check in 3D and on a 2D field map. Result: a task that usually depends heavily on manual attention becomes faster, more systematic, and repeatable. #ReservoirEngineering #Drilling #Python #EngineeringAutomation #AI
To view or add a comment, sign in
-
💡 Cracking the Maximum Product Subarray Problem (Without Overcomplicating It) Today I worked on a classic DSA problem: Maximum Product Subarray — and found a simple yet powerful approach worth sharing. Most solutions focus on tracking max/min dynamically. But there’s a cleaner trick: 👉 Traverse the array from both directions (prefix & suffix) Why this works: Negative numbers can flip the product sign A single left-to-right pass might miss the optimal answer Scanning from both ends ensures we capture every possibility 🔁 Key Idea: Maintain two running products: Prefix (left → right) Suffix (right → left) Reset when product becomes 0 Track the maximum throughout ⚡ Complexity: Time: O(n) Space: O(1) Python code : https://lnkd.in/gZtCw9_i What I liked about this approach is its simplicity and elegance — no extra arrays, no complex state tracking. Sometimes, the best solutions aren’t the most complicated ones — just the most thoughtful. Have you tried solving this problem using a different approach? Would love to hear your thoughts 👇 #DataStructures #Algorithms #CodingInterview #Python #LeetCode #ProblemSolving Rajan Arora
To view or add a comment, sign in
-
-
Top K Frequent: Bucket Sort Beats Heap with O(n) Time Heap solution costs O(n log k). Bucket sort achieves O(n) by exploiting constraint — frequencies ≤ array length. Index represents frequency, value is list of elements with that frequency. Traverse high-to-low, collecting k elements. Bucket Sort Advantage: When value range is bounded (frequencies ≤ n), bucket sort beats comparison-based sorting. Exploiting constraints transforms complexity. Time: O(n) | Space: O(n) #BucketSort #TopK #FrequencyAnalysis #ComplexityReduction #Python #AlgorithmOptimization #SoftwareEngineering
To view or add a comment, sign in
-
-
📌 Problem: Increasing Triplet Subsequence 💡 Approach: Traverse the array while maintaining two variables: first and second, representing the smallest and second smallest values found so far. If the current number is smaller than first, update first Else if it’s smaller than second, update second If a number is greater than both, we’ve found an increasing triplet This ensures an optimal single-pass solution. ⚙️ Key Insight: Track only two values instead of checking all triplets Greedy + optimization approach reduces complexity significantly ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) 📚 What I learned: Greedy strategy for subsequence problems Reducing brute-force O(n³) to optimal linear solution #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #Greedy #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
Reorder Linked List: Split, Reverse, Merge Pattern Reordering a linked list looks tricky at first, but it becomes clean once you break it into three deterministic steps: Find the middle Reverse the second half Merge both halves alternately The key insight is: instead of trying to rearrange nodes in one pass, decompose the problem into simpler sub-problems you already know how to solve efficiently. Complexity: Time: O(n) | Space: O(1) Takeaway: Many linked list problems follow a hidden pattern: 👉 Split → Transform → Merge Once you recognize this, problems like palindrome check, reorder list, and even some cycle-based problems become much easier. #LinkedList #TwoPointers #InPlaceAlgorithms #CodingInterview #ProblemSolving #Python #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 28 of Problem Solving Journey Today, I worked on an interesting problem: Group Anagrams 🔍 Problem Statement: Given an array of strings, group the anagrams together. Anagrams are words that have the same characters but arranged differently. 💡 Approaches I explored: ✅ Approach 1: Character Frequency Count (Optimized) Used a fixed-size array (26 letters) to count character occurrences Converted the count into a tuple to use as a dictionary key Achieved an efficient time complexity of O(n * k) ✅ Approach 2: Sorting Strings Sorted each string and used it as a key Simple and intuitive approach Time complexity: O(n * k log k) 📌 Key Learning: Understanding how hashing works with different representations (frequency vs sorted string) helps in optimizing solutions. ⚡ Takeaway: There are always multiple ways to solve a problem, but choosing the most efficient one makes a difference in real-world applications and interviews. 💻 Tech Used: Python | HashMap | Arrays #Day28 #ProblemSolving #Python #DataStructures #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Today: LeetCode 88 — Merge Sorted Array. Saw "sorted arrays" in the problem. My brain immediately said: two pointers. Started coding. Got stuck pretty fast. The issue? When you're merging into an existing array without extra space, two pointers aren't enough — you need a third one tracking where to place elements. And you have to go backwards through nums1, or you'll overwrite values you still need. Took longer than I'd like to admit. Used hints. Eventually got it — and it beat 100% on runtime. The real lesson wasn't the algorithm. It was this: pattern recognition gets you to the door, but you still have to figure out which version of the pattern fits. "Two pointers" is a family of techniques, not a single move. Knowing the name isn't the same as understanding the shape of the problem. Day 36 of #1000DaysOfLearning #DSA #Python #LearningInPublic
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