← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE interview with a string manipulation problem. Pretty standard stuff but worth knowing the edge cases cold before you walk in.

Questions Asked (1)

Q1

Given two strings s and t of equal length, determine if they are isomorphic. That means every character in s maps to exactly one character in t, and no two characters in s map to the same character in t, while preserving order.

Algorithms & Data Structures
Author's notes

Seemed easy at first and I jumped straight to using one hashmap.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use two hash maps to track the bijective mapping between characters of s and t. Iterate through both strings simultaneously, checking that each character in s maps consistently to the corresponding character in t and vice versa. If any inconsistency is found, return false; otherwise, return true.

Pro tip: Clarify edge cases upfront, such as empty strings or strings with repeated patterns, and mention that the solution runs in O(n) time with O(1) space if the character set is fixed (e.g., ASCII).

1. Clarify the problem

Confirm that isomorphic means a one-to-one mapping between characters of s and t, preserving order, and that both strings are of equal length. Ask about character set (e.g., ASCII, Unicode) to determine space complexity.

2. Choose data structures

Use two hash maps (dictionaries) to store mappings from s to t and from t to s. Alternatively, use arrays of size 256 for ASCII to achieve O(1) space.

3. Iterate and validate

Loop through each index i, and check if s[i] is already mapped to a different character in t, or if t[i] is already mapped from a different character in s. If either condition fails, return false.

4. Update mappings

If no conflict, record the mappings s[i] -> t[i] and t[i] -> s[i] in the respective hash maps.

5. Return result

After the loop, return true, indicating the strings are isomorphic. Discuss time and space complexity: O(n) time and O(1) space for fixed character set.

Key Points to Mention

  • Bijective mapping requirement: each character in s maps to exactly one in t and vice versa.
  • Use of two hash maps to enforce one-to-one correspondence.
  • Time complexity: O(n) where n is the length of the strings.
  • Space complexity: O(1) if character set is fixed (e.g., ASCII), otherwise O(k) where k is the number of unique characters.
  • Edge cases: empty strings, strings with all same characters, and strings with no repeating characters.
  • Alternative approach: using arrays for ASCII to optimize space and speed.

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