← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber SWE coding round, one string problem that looks deceptively simple but has a slick O(n) solution most people probably don't know cold.

Questions Asked (1)

Q1

Given a string, determine whether it can be formed by repeating a smaller substring of itself multiple times.

Algorithms & Data Structures
Author's notes

I knew there was a clever trick here but blanked on it mid-interview and just went with the brute force: try every possible prefix length that divides the total length, check if tiling it reproduces the string.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem and edge cases, then present an efficient solution such as checking if the string is a substring of itself doubled (excluding the first and last characters). Discuss time/space complexity and consider alternative approaches like KMP or string concatenation.

Pro tip: Mention that the doubled-string trick works because if the string is periodic, it will appear in the middle of its double; this shows deep understanding and avoids unnecessary complexity.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., string length, character set) and confirm edge cases like empty string or length 1. This demonstrates thoroughness.

2. Brainstorm approaches

Consider brute-force (checking all possible substring lengths) and optimized methods (string doubling, KMP). Explain trade-offs.

3. Present the optimal solution

Describe the doubled-string approach: if s is a repetition, it will be a substring of (s+s) excluding the first and last characters. Provide code or pseudocode.

4. Analyze complexity

State time and space complexity: O(n) time with O(n) space for the doubled string, or O(1) space if using KMP on the original string.

5. Test with examples

Walk through examples like 'abab' (true) and 'aba' (false) to validate the solution and edge cases.

Key Points to Mention

  • The doubled-string trick: s is a repetition iff s is a substring of (s+s)[1:-1].
  • Time complexity: O(n) using string search (e.g., KMP) or O(n^2) naive.
  • Space complexity: O(n) for doubled string, O(1) extra with KMP.
  • Edge cases: empty string (usually false), single character (false), strings with no repetition.
  • Alternative approach: using KMP to find the longest proper prefix that is also a suffix.
  • Proof of correctness: if s = t^k, then s appears in the middle of s+s.

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