𝗦𝗼𝗹𝘃𝗲𝗱 𝘁𝗵𝗲 𝗠𝗶𝗻𝗶𝗺𝘂𝗺 𝗪𝗶𝗻𝗱𝗼𝘄 𝗦𝘂𝗯𝘀𝘁𝗿𝗶𝗻𝗴 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗶𝗻 𝗣𝘆𝘁𝗵𝗼𝗻 Today, I worked on the Minimum Window Substring problem and implemented it using three different approaches to understand how we can optimize code step by step. 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵𝗲𝘀 𝗨𝘀𝗲𝗱 • Brute Force Approach • Better Approach using HashMap and Count • Optimized Sliding Window Approach 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗦𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁 Given two strings: S = "ADOBECODEBANC" T = "ABC" The goal is to find the smallest substring in S that contains all characters of T. Output: "BANC" 𝗧𝗶𝗺𝗲 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 𝗖𝗼𝗺𝗽𝗮𝗿𝗶𝘀𝗼𝗻 • Brute Force: O(n² × m) • Better Approach: O(n²) • Optimized Sliding Window: O(n) 𝗞𝗲𝘆 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴𝘀 • How HashMaps help in tracking character frequencies • Why repeated checking inside loops makes code slower • How the Sliding Window technique improves performance • How to think from brute force to optimized solution The Sliding Window approach was the best solution because it processes the string efficiently using left and right pointers. GitHub Repository: https://lnkd.in/gPy8Kcam #Python #DSA #Algorithms #SlidingWindow #Programming #CodingInterview #LeetCode #SoftwareDevelopment #PythonDeveloper
Minimum Window Substring Problem Solution in Python
More Relevant Posts
-
Built a Python-based Directory Sync Tool to compare and synchronize files between two directories with reliability and control. Instead of relying only on file names or timestamps, the tool uses a combination of metadata and SHA-256 hashing to accurately detect new, modified, and missing files. Key highlights: • Recursive directory scanning with structured metadata (name, extensions, size, hash) • Efficient change detection using size-first filtering followed by hash comparison • Memory-efficient hashing using chunk-based file reading (handles large files) • Synchronization support with metadata preservation using shutil.copy2 • Safe cleanup by optionally removing extra files from the destination While building this, I focused on moving beyond a basic script and treating it like a real tool, structuring the code into clear components, improving output readability, and adding validation and error handling to make it more reliable in real use. GitHub:https://lnkd.in/gt-Ec3rF #Python #CLI #GitHubProjects #SoftwareDevelopment #LearningByBuilding #SystemsThinking
To view or add a comment, sign in
-
WerWolf is an in-memory implementation of the Silent Process Exit LSASS dumping technique, initially introduced by Asaf Gilboa at DEF CON 30. It uses a custom Python COFF loader to execute this technique without writing executables to disk, avoiding PowerShell, script block logging, and AMSI. 🔗 https://lnkd.in/gp-cvF6H
To view or add a comment, sign in
-
📁 Day 24: Mastering File Systems & Mail Merging I just automated a tedious administrative task by building a Mail Merge program that handles file I/O and string manipulation with ease! 💡 Fun Fact: The concept of "Mail Merge" dates back to the 1970s with early word processors like WordStar, saving humans millions of hours by separating the content from the contact list. 🚀 Key Features: • File Automation: Reads template files and recipient lists dynamically. • String Cleaning: Uses .strip() and .replace() to personalize content. • Scalable Output: Automatically generates and saves unique letters for every name. Explore the automation logic here: 🔗https://lnkd.in/gwdWmATu #Python #Automation #FileHandling #PythonProjects #Coding #100DaysOfCode
To view or add a comment, sign in
-
Spent 5 days chasing ghosts—DLL hell and ABI mismatches. I followed the agentic debugger down the wrong path as it hallucinated at a wrong layer because it misread the WinError 1114 as a load-path issue rather than a missing export. The actual fix was two lines. I used TORCH_LIBRARY when I needed PYBIND11_MODULE. The Architecture Gap: - Use TORCH_LIBRARY to register ops into the PyTorch C++ Dispatcher (accessed via torch.ops). It fires static C++ constructors at DLL load time but does not create a PyInit_* function. Python can't "see" it as a module. - Use PYBIND11_MODULE to generate the standard Python C Extension entry point. This generates the PyInit_{name} entry point Python needs to "see" the module. The error was literal: "dynamic module does not define module export function." No PyInit_* existed because TORCH_LIBRARY isn't meant to be imported directly. {just correcting the record} #CPP #PyTorch #SystemsProgramming #MachineLearning #barebones #3D
To view or add a comment, sign in
-
I’ve been focusing on strengthening fundamentals by building small, intentional utilities instead of relying on built-ins. Recently, I put together a Python toolkit that implements: *average calculation from scratch *max/min via iteration (no built-ins) *occurrence counting with explicit control flow *palindrome detection using a two-pointer approach *a reporting function that composes results from multiple helpers The goal wasn’t complexity—it was clarity. Writing the logic out step-by-step and debugging edge cases (like initialization bugs and boundary conditions) made a noticeable difference in how I approach problems. This kind of work is where patterns start to stick—loops, conditionals, and data flow all working together instead of in isolation.
To view or add a comment, sign in
-
Worked on an Event Scheduler project in today’s CPSC 335 (Algorithms) class, implementing it in Python using a combination of data structures. I used a min-heap for efficient priority handling, a hash table for O(1) lookups, and a sorted list for time-based queries. This exercise was a great way to see how different data structures can be combined to balance performance and functionality, and how trade-offs play a key role in algorithm design.
To view or add a comment, sign in
-
Ah posit::conf(2025) how we miss you! 👋 Ever wished you could juggle multiple R or Python sessions without spinning up a second window? In this talk, Dhruvi Sompura walks through one of Positron's most-loved features: Multiple Console Sessions. 📽️ Run several R and Python consoles side by side in a single Positron window. Switch between projects, compare environments, test package versions, or keep a long-running job humming in one console while you keep coding in another. It's a small change that unlocks a much smoother data science workflow. Never fear! posit::conf(2026) planning is well underway... https://lnkd.in/e6q9C69U
To view or add a comment, sign in
-
I used to think tuples were just “lists with stricter rules”… but today showed me they have their own vibe. 🐍 Day 06 of my #30DaysOfPython journey was all about tuples, and this topic made one thing really clear: sometimes the best data structure is the one that stays put. A tuple is an ordered and unchangeable collection of different data types, created using round brackets (). Today I explored: 1. Creating tuples with tuple() 2. Accessing items using positive and negative indexing 3. Slicing tuples with positive and negative indexes 4. Checking whether an item exists using in 5. Counting items with count() 6. Finding item positions with index() 7. Joining tuples using + operator 8. Converting tuples to lists with list() 9. Deleting the whole tuple using del What stood out to me today was how tuples are built for stability. They are not meant to be edited over and over again — and that actually makes them really useful when you want data to stay consistent. One more day, one more topic, one more layer of Python making sense. Github Link - https://lnkd.in/gHwugKTU #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
50 episodes live. 50 growth marketing distortions diagnosed. 8 pillars covered. Zero schema violations. Each episode diagnoses a specific moment where a dashboard metric looks healthy while the underlying business signal is broken. Every episode includes: — Interactive diagnostic calculator — Convergent validity across 5+ industries — Confidence score with five-dimension methodology — Step-by-step platform walkthroughs — Downloadable audit template Built on a renderer-driven production engine with a Python validation pipeline and cross-system governance. Halfway to 100. The second 50 starts now.
To view or add a comment, sign in
-
-
LeetCode Day 13 – Container With Most Water Today I solved the classic “Container With Most Water” problem — a great example of optimizing from brute force to an efficient solution! Problem Insight: We are given an array of heights, and we need to find two lines that together with the x-axis form a container that holds the maximum water. Approaches: Brute Force (O(n²)) Check all possible pairs Calculate area = width × min(height[i], height[j]) Keep track of maximum Optimal Approach – Two Pointer (O(n)) Start with two pointers at both ends Calculate area Move the pointer with smaller height inward Repeat until pointers meet Key Idea: The limiting factor is always the smaller height Moving the larger height won’t help increase area Complexity: Time: O(n) Space: O(1) What I learned: How two-pointer technique drastically reduces complexity Importance of understanding constraints before coding #LeetCode #Day13 #DSA #CodingJourney #Python #TwoPointers #ProblemSolving
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