PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of numeric and string manipulation along with algorithmic problem-solving for palindrome detection and generation, including handling large integers and edge cases.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Check palindrome number and next palindrome

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem You are given a **non-negative integer** `n`. 1. Determine whether `n` is a palindrome in base-10 (it reads the same forward and backward). 2. **Follow-up:** Return the **smallest palindrome integer strictly greater than `n`**. ### Examples - `n = 1221` → palindrome: `true` - `n = 999` → palindrome: `true` - `n = 132` → next palindrome: `141` - `n = 9` → next palindrome: `11` - `n = 10` → next palindrome: `11` ### Input / Output - Input: integer `n` - Output: - Part (1): boolean - Part (2): integer ### Constraints (assume) - `0 ≤ n ≤ 10^18` (so solutions should not rely on converting to a fixed-size 32-bit int) - The follow-up should be efficient for large `n` (avoid incrementing one-by-one).

Quick Answer: This question evaluates understanding of numeric and string manipulation along with algorithmic problem-solving for palindrome detection and generation, including handling large integers and edge cases.

Palindrome Number

Return whether a non-negative integer is a base-10 palindrome.

Examples

Input: (1221,)

Expected Output: True

Explanation: Palindrome.

Input: (123,)

Expected Output: False

Explanation: Not palindrome.

Input: (0,)

Expected Output: True

Explanation: Zero.

Next Palindrome Number

Return the smallest palindrome integer strictly greater than n.

Examples

Input: (132,)

Expected Output: 141

Explanation: Next is 141.

Input: (9,)

Expected Output: 11

Explanation: Single digit.

Input: (10,)

Expected Output: 11

Explanation: Next 11.

Input: (999,)

Expected Output: 1001

Explanation: Carry increases length.

Input: (1221,)

Expected Output: 1331

Explanation: Strictly greater.

Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)