← LinkedIn Interview Insights

LinkedIn·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

LinkedIn software engineer interview with two coding problems back to back. One was a classic sliding window, the other was a custom graph/logic puzzle that I didn't see coming at all.

Questions Asked (2)

Q1

Given two strings s and t, find the smallest substring of s that contains all characters of t, including duplicates.

Algorithms & Data Structures
Author's notes

Knew this was a sliding window problem pretty fast, which was a relief.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window with two pointers to expand and contract a window over s while tracking character counts of t. Maintain a count of matched characters to know when the window is valid, and record the smallest valid window. This yields O(n) time and O(k) space, where k is the number of distinct characters in t.

Pro tip: Clarify edge cases upfront (e.g., t longer than s, empty strings, Unicode) and mention that the algorithm runs in O(n) time, which is optimal since you must scan s at least once. Also, discuss how you would handle large inputs or streaming data if relevant.

1. Understand the problem and edge cases

Restate the problem to confirm requirements: smallest substring of s containing all characters of t, including duplicates. Ask about edge cases: empty strings, t longer than s, characters outside ASCII, and whether the answer is guaranteed to exist.

2. Choose the right approach

Propose a sliding window (two-pointer) technique because it efficiently finds the minimum window in linear time. Explain why brute force is inefficient and why sliding window is optimal.

3. Design the algorithm

Use a hash map to count characters in t. Expand the right pointer to include characters, updating counts and a 'formed' counter. When all characters are matched, contract the left pointer to minimize the window while keeping it valid, updating the minimum length and start index.

4. Analyze complexity and test

State time complexity O(n) and space O(k) where k is distinct characters in t. Walk through a small example to verify correctness, and consider edge cases like no valid window.

5. Discuss optimizations and variations

Mention possible optimizations (e.g., filtering s to only relevant characters) and variations (e.g., finding all minimum windows, handling streaming input).

Key Points to Mention

  • Sliding window technique with two pointers
  • Hash map to track character frequencies of t and the current window
  • Counter for matched characters to determine window validity
  • Time complexity O(n) and space complexity O(k)
  • Edge cases: empty strings, t longer than s, no valid window, Unicode characters
  • Comparison with brute force O(n^2) approach

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

You're given a hashmap where each key is an animal and the value is a list of animals that can't be on the same river bank as it. Determine whether the set of exclusion rules is conflict-free (i.e., no contradictions exist).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one threw me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the exclusion rules as an undirected graph where each animal is a vertex and each exclusion is an edge. The rules are conflict-free if and only if the graph is bipartite, meaning it can be 2-colored without adjacent vertices sharing the same color. Use BFS or DFS to check bipartiteness, handling disconnected components.

Pro tip: Clarify that 'conflict-free' means no two animals that can't be together are forced to be on the same bank. Mention that self-loops (an animal excluding itself) immediately make it impossible, and that the problem reduces to bipartite checking.

1. Understand the problem

Restate the problem: we need to assign each animal to one of two banks such that no exclusion rule is violated. Recognize that this is equivalent to 2-coloring a graph.

2. Build the graph

Create vertices for each animal. For each key and each animal in its exclusion list, add an undirected edge between them. Ensure the graph is undirected and handle duplicates.

3. Check bipartiteness

Use BFS or DFS to attempt to 2-color the graph. Start from each unvisited vertex, assign a color, and propagate colors to neighbors, flipping the color at each step. If a neighbor already has the same color, a conflict exists.

4. Handle edge cases

Check for self-loops (an animal excluding itself) which immediately cause a conflict. Also consider disconnected components and ensure all vertices are visited.

5. Return result

If all components are successfully 2-colored without conflicts, return true (conflict-free). Otherwise, return false.

Key Points to Mention

  • Graph representation: animals as vertices, exclusions as edges.
  • Bipartite graph and 2-coloring equivalence.
  • BFS/DFS traversal for coloring and conflict detection.
  • Handling disconnected components by iterating over all vertices.
  • Self-loops as immediate conflicts.
  • Time and space complexity: O(V + E) time, O(V) space.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.