PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of string algorithms, frequency-based sliding window techniques and hashmap/graph-based conflict detection, focusing on minimal substring search and modeling pairwise exclusions.

  • medium
  • LinkedIn
  • Coding & Algorithms
  • Software Engineer

Solve min window & animal conflicts

Company: LinkedIn

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

##### Question LeetCode 76. Minimum Window Substring: Given strings s and t, return the smallest substring of s that contains every character of t (including duplicates). Validate a hashmap where each key is an animal and its value is a list of animals that cannot share the same river bank; determine whether the exclusions are conflict-free. https://leetcode.com/problems/minimum-window-substring/description/

Quick Answer: This question evaluates understanding of string algorithms, frequency-based sliding window techniques and hashmap/graph-based conflict detection, focusing on minimal substring search and modeling pairwise exclusions.

Given a string s, a string t, and an exclusion map exclusions where each key is an animal and its value is a list of animals that cannot share the same river bank, return a two-element list [min_window, conflict_free]. min_window is the smallest substring of s that contains every character of t (including duplicates); return an empty string if no such substring exists. conflict_free is true if the undirected graph formed by treating each exclusion as an edge is bipartite (i.e., the animals can be split into two banks so that no excluded pair is on the same bank), and false otherwise. A self-exclusion (an animal excluding itself) makes the configuration not conflict-free. Animals mentioned only in values are still considered nodes.

Constraints

  • 0 <= len(s) <= 200000
  • 0 <= len(t) <= 200000
  • s and t consist of ASCII characters
  • Number of distinct animals <= 100000
  • Sum of lengths of all exclusion lists <= 200000
  • Exclusions are treated as undirected edges
  • Self-exclusion (animal listed as excluding itself) makes conflict_free = false

Hints

  1. For the minimum window, use a sliding window with frequency counts: expand right until all required counts are met, then contract left to minimize.
  2. Treat exclusions as an undirected graph; check bipartiteness with BFS/DFS coloring across all components.
  3. Watch for self-loops (an animal excluding itself), which immediately make the graph not bipartite.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Longest Run of Ones After One Flip - LinkedIn (medium)
  • The Celebrity Problem - LinkedIn (medium)
  • Count Trips From Vehicle Logs - LinkedIn (easy)
  • Process Mutable Matrix Sum Queries - LinkedIn (medium)
  • Design O(1) Randomized Multiset - LinkedIn (easy)