← Lyft Interview Insights

Lyft·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Lyft software engineer screen, one coding problem the whole time. The twist was no test cases handed to you, you had to come up with your own, which honestly changed the feel of the whole thing.

Questions Asked (1)

Q1

Given two strings, find the shortest contiguous substring of the source string that contains all characters of the target string, including duplicates. Return an empty string if none exists. You must also design your own test cases.

Algorithms & Data Structures
Author's notes

The sliding window part I was fine with, two pointers, frequency maps, shrink from the left when valid.

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 the window while tracking character frequencies. Maintain a count of matched characters to know when the window contains all target characters, and record the minimum length. Then design test cases covering edge cases like empty strings, no solution, and duplicates.

Pro tip: Clarify upfront that the target may contain duplicate characters and that the window must contain at least the same count of each. Mention that the algorithm runs in O(n) time using a frequency map, which is optimal for this problem.

1. Clarify requirements and edge cases

Confirm that the substring must contain all characters of the target including duplicates, and that if no such substring exists, return an empty string. Discuss edge cases like empty source or target, target longer than source, and characters not in source.

2. Design the sliding window algorithm

Use two pointers (left and right) to represent a window. Expand right to include characters until the window is valid (contains all target characters with required counts), then contract left to find the smallest valid window. Track the minimum length and starting index.

3. Implement frequency tracking

Use a hash map to count characters needed from the target. As you expand the window, decrement the needed count for each character. Maintain a 'formed' counter to track how many unique characters have met the required count. When formed equals the number of unique characters in target, the window is valid.

4. Optimize and handle edge cases

After finding a valid window, contract from the left while the window remains valid, updating the minimum length. If the minimum length is never updated, return an empty string. Ensure the algorithm handles cases where target has characters not in source.

5. Design test cases

Create test cases covering: normal case with duplicates, no valid substring, empty strings, target longer than source, and characters with varying frequencies. Include a case where the shortest substring is at the beginning or end.

Key Points to Mention

  • Sliding window technique with two pointers for O(n) time complexity
  • Frequency map to track required character counts and handle duplicates
  • Maintaining a 'formed' count to know when the window is valid
  • Updating minimum length and start index when a valid window is found
  • Edge cases: empty strings, no solution, target longer than source
  • Test cases should include duplicates and varying character frequencies

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