← Yahoo Interview Insights

Yahoo·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Coding round for a Data Scientist role at Yahoo, two Python problems focused on list manipulation. Nothing too wild but the second question had some edge cases that could trip you up if you weren't careful.

Questions Asked (2)

Q1

Given a list of integers, remove all duplicates while keeping the elements in their original order.

Algorithms & Data Structures
Author's notes

Pretty standard dedup problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., data size, memory limits, whether the list can be modified) and then propose a solution using a hash set to track seen elements while building the output list. Discuss time and space complexity, and mention alternative approaches if constraints differ.

Pro tip: Mention that in Python, you can use a dictionary to preserve order (since Python 3.7) or an OrderedDict for older versions, but explicitly using a set is more memory-efficient and demonstrates deeper understanding. Also, consider edge cases like empty list or all duplicates.

1. Clarify requirements

Ask about input size, memory constraints, whether the list can be modified in-place, and if the output should be a new list or modified original.

2. Propose optimal solution

Use a set to track seen elements and a list to store the result, iterating through the input once. This preserves order and runs in O(n) time.

3. Analyze complexity

State that time complexity is O(n) and space complexity is O(n) due to the set and output list. Mention that if memory is tight, sorting could be used but would lose order.

4. Discuss alternatives and trade-offs

Mention that using a dictionary (or OrderedDict) also works but may have slightly higher overhead. If the list is sorted, a two-pointer approach could work in O(n) time and O(1) extra space, but order is not preserved.

5. Handle edge cases

Consider empty list, single element, all duplicates, and non-hashable elements (if applicable). Also, discuss if the input is a stream or very large, requiring a different approach.

Key Points to Mention

  • Time and space complexity analysis (O(n) time, O(n) space)
  • Use of a hash set for O(1) lookups to track seen elements
  • Preservation of original order by iterating sequentially
  • Alternative approaches: using dict.fromkeys() in Python, or sorting if order doesn't matter
  • Edge cases: empty list, all duplicates, large input
  • Trade-offs between memory usage and speed

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

Q2

Given a list of lowercase words, merge them into a single string by overlapping the last character of each word with the first character of the next word whenever they match. For example, ['abc','rgn','ctr'] produces 'abctrgn'. You also need to handle cases where there's no overlap or potentially multiple overlapping characters.

Algorithms & Data Structures
Author's notes

This one took me longer than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the overlap rule: the last character of the current merged string must match the first character of the next word, and if multiple overlaps are possible, choose the longest overlap to avoid losing characters. Then implement a greedy algorithm that iterates through the list, merging each word by finding the maximum overlap with the current result. Discuss edge cases like no overlap, empty list, and single word.

Pro tip: Always confirm with the interviewer whether the overlap should be the longest possible or just the first match, as this ambiguity can drastically change the output. Also, mention that you would test with words that have multiple overlapping characters (e.g., 'aaa' and 'aaab') to ensure correctness.

1. Clarify requirements and edge cases

Ask about the overlap rule: should it be the longest overlap? What if multiple overlaps exist? Also consider empty list, single word, and words with no overlap.

2. Design the algorithm

Use a greedy approach: start with the first word as the result. For each subsequent word, find the maximum k such that the last k characters of the result match the first k characters of the word, then append the word without its first k characters.

3. Implement and test

Write code to compute the overlap efficiently (e.g., using string slicing or KMP for large inputs). Test with examples like ['abc','rgn','ctr'] and edge cases like ['a','a','a'].

4. Analyze complexity and optimize

Discuss time complexity: naive overlap check is O(n*m) per merge, but can be optimized. Mention potential improvements if needed.

Key Points to Mention

  • Definition of overlap: last character of current string matches first character of next word, but consider multiple overlapping characters.
  • Greedy merging strategy: process words sequentially, always merging the next word with the current result.
  • Maximum overlap selection: when multiple overlaps are possible, choose the longest to minimize length and avoid data loss.
  • Edge cases: empty list, single word, no overlap, and words that are substrings of each other.
  • Time and space complexity: O(n*m) naive, potential optimizations using string matching algorithms.
  • Testing: include examples with multiple overlaps (e.g., ['aaa','aaab'] -> 'aaab') and no overlap (e.g., ['abc','def'] -> 'abcdef').

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