PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Uber

Find next and closest palindromes

Last updated: Mar 29, 2026

Quick Overview

This question evaluates string-based numeric manipulation and palindrome construction, including edge-case handling (all 9s, single-digit inputs, length changes), candidate generation and magnitude comparison of large numbers as strings, and carry propagation for fixed-length decimal palindromes.

  • Medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Find next and closest palindromes

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Given a non-negative integer represented as a string n (no leading zeros unless n == "0"), return the smallest palindromic integer strictly greater than n. Return the answer as a string. Aim for O(n) time and O( 1) extra space besides the output. Discuss how you handle edge cases such as all 9s, single-digit inputs, and length changes (e.g., "99" -> "101"). Follow-up A: Modify your solution to return the palindrome (not equal to n) with minimal absolute difference to n; if there is a tie, return the smaller palindrome. Explain which candidate palindromes you generate and how you compare magnitudes without using big-integer libraries. Follow-up B: If the input is a decimal number with a fixed number of fractional digits (e.g., "123.450"), define a palindromic decimal as one where the '.' mirrors itself and the digits mirror across it. Return the smallest palindromic decimal strictly greater than the input under this definition. Describe how you propagate carries across the decimal point and how you preserve the fixed fractional length.

Quick Answer: This question evaluates string-based numeric manipulation and palindrome construction, including edge-case handling (all 9s, single-digit inputs, length changes), candidate generation and magnitude comparison of large numbers as strings, and carry propagation for fixed-length decimal palindromes.

Related Interview Questions

  • Implement stream queries and bounded-difference subarrays - Uber (medium)
  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Simulate a Rank-Based Tournament - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
Uber logo
Uber
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
4
0

Given a non-negative integer represented as a string n (no leading zeros unless n == "0"), return the smallest palindromic integer strictly greater than n. Return the answer as a string. Aim for O(n) time and O(

  1. extra space besides the output. Discuss how you handle edge cases such as all 9s, single-digit inputs, and length changes (e.g., "99" -> "101"). Follow-up A: Modify your solution to return the palindrome (not equal to n) with minimal absolute difference to n; if there is a tie, return the smaller palindrome. Explain which candidate palindromes you generate and how you compare magnitudes without using big-integer libraries. Follow-up B: If the input is a decimal number with a fixed number of fractional digits (e.g., "123.450"), define a palindromic decimal as one where the '.' mirrors itself and the digits mirror across it. Return the smallest palindromic decimal strictly greater than the input under this definition. Describe how you propagate carries across the decimal point and how you preserve the fixed fractional length.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.