← Waymo Interview Insights

Waymo·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Waymo SWE interview with a string manipulation problem. Pretty standard coding round, nothing too wild, but the question had a specific approach they seemed to want.

Questions Asked (1)

Q1

Given two strings, one defining a custom character ordering and one as the target, rearrange the target string so its characters appear in the order defined by the first string. Characters not present in the ordering string can go anywhere.

Algorithms & Data Structures
Author's notes

The core idea clicks pretty fast: count frequencies in the target, then walk through the ordering string and append each character the right number of times, then tack on whatever's left.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then propose an efficient solution using a hash map to store the custom order and a stable sort or counting sort to rearrange the target string. Analyze time and space complexity, and discuss potential optimizations or alternative approaches.

Pro tip: Mention that characters not in the custom order can be placed at the end or beginning, but be explicit about your choice and ensure it doesn't affect the relative order of the ordered characters. Also, consider using a stable sort to maintain the original order of characters with the same custom order index.

1. Clarify Requirements and Edge Cases

Ask about the character set (ASCII/Unicode), whether the custom order string contains duplicates, and how to handle characters not in the order. Confirm if the output should be stable for characters with the same order index.

2. Choose Data Structures

Use a hash map to map each character in the custom order to its index. For rearranging, consider counting sort (if character set is small) or a stable sort with a custom comparator.

3. Design the Algorithm

Iterate through the custom order, and for each character, append all its occurrences from the target string to the result. Then append any remaining characters not in the custom order. Alternatively, sort the target string using the custom order as the key.

4. Analyze Complexity

Discuss time and space complexity. For counting sort: O(n + k) time and O(k) space, where k is the size of the custom order. For sorting: O(n log n) time. Mention trade-offs.

5. Test with Examples

Walk through a few test cases, including empty strings, characters not in the order, and duplicates. Verify correctness and edge cases.

Key Points to Mention

  • Hash map for O(1) lookup of custom order indices
  • Stable sorting to preserve original order of characters with the same custom order index
  • Counting sort for linear time when character set is limited
  • Handling characters not in the custom order (e.g., append at the end)
  • Time and space complexity analysis
  • Edge cases: empty strings, all characters not in order, duplicates in custom order

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