Solve min window & animal conflicts
Company: LinkedIn
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
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.
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
- For the minimum window, use a sliding window with frequency counts: expand right until all required counts are met, then contract left to minimize.
- Treat exclusions as an undirected graph; check bipartiteness with BFS/DFS coloring across all components.
- Watch for self-loops (an animal excluding itself), which immediately make the graph not bipartite.