Uber Coding Interview: Odometer Mirror Reading

Based on questions reported for Uber interviews

The interviewer opens

Welcome, and thanks for joining this interview for the software engineer role at Uber. We'll work through a coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause any time with the Pause button at the top right.

The problem is about building a mirrored version of a trip's odometer reading, and it's up in the Problem tab now. Please read it through, take your time, and let me know if you have any questions before you start.

The problem

A trip reading is a very long non-negative integer given as a string, and you build its mirrored reading.

  • s: a string of decimal digits with no leading zeros ("0" itself is allowed).

Return the palindrome of the same length whose first half is the first half of s. When the length is odd, the middle digit of s is kept and belongs to the first half. Mirror the first half onto the second half.

Example: s = "12345" → "12321"

1 ≤ len(s) ≤ 10^5.