← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Went through a coding round at Uber for a software engineer role. Pretty standard algorithmic problem but there's more nuance to it than you'd expect if you haven't thought about palindromes in a while.

Questions Asked (1)

Q1

Given a string, find and return the longest palindromic substring.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was the DP table approach because it felt safe and I could explain it cleanly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., input size, character set) and discussing brute-force versus optimized solutions. Then present an O(n^2) expand-around-center approach as a balance of simplicity and efficiency, and optionally mention Manacher's algorithm for O(n) if needed. Walk through the algorithm with a small example and analyze time/space complexity.

Pro tip: Demonstrate awareness of trade-offs: expand-around-center is easier to implement and less error-prone than Manacher's, which is complex and rarely expected in interviews unless explicitly asked. Also, handle edge cases like empty string and single character early.

1. Clarify requirements and constraints

Ask about input size, character set, and whether the palindrome must be contiguous. Confirm return type (substring vs. length) and handle edge cases like empty string.

2. Discuss possible approaches

Mention brute-force O(n^3), dynamic programming O(n^2), expand-around-center O(n^2), and Manacher's O(n). Compare their trade-offs in terms of implementation complexity and performance.

3. Choose and explain the optimal approach

Select expand-around-center for its simplicity and good average performance. Explain how to expand around each character (odd length) and each pair (even length) to find the longest palindrome.

4. Walk through an example

Trace the algorithm on a sample string like 'babad' to show how it finds 'bab' or 'aba'. Highlight how you track the start index and max length.

5. Analyze complexity and edge cases

State time complexity O(n^2) and space O(1). Discuss edge cases: empty string, single character, all same characters, and no palindrome longer than 1.

Key Points to Mention

  • Time and space complexity of each approach
  • Expand-around-center technique for odd and even length palindromes
  • Handling edge cases: empty string, single character, no palindrome
  • Trade-offs between simplicity (expand-around-center) and optimality (Manacher's)
  • Tracking the start index and maximum length during expansion
  • Potential follow-up: return the actual substring, not just length

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