PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This two-part question evaluates numeric digit-manipulation and interval-merging competencies, specifically integer palindrome detection (accounting for sign and integer limits) and combining overlapping ranges via sorting and range aggregation in the Coding & Algorithms domain.

  • hard
  • Google
  • Coding & Algorithms
  • Software Engineer

Check Digits and Combine Ranges

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are asked to solve two independent coding tasks. ### Task 1: Check Whether an Integer Reads the Same Backward Given an integer `x`, return `true` if its decimal representation reads the same from left to right and from right to left; otherwise return `false`. Requirements and edge cases: - Negative integers should return `false` because of the leading minus sign. - You may assume `x` fits in a signed 32-bit integer. - Try to solve it without converting the integer to a string. Example: ```text Input: x = 121 Output: true ``` ```text Input: x = -121 Output: false ``` ```text Input: x = 10 Output: false ``` ### Task 2: Combine Overlapping Ranges Given an array of intervals `intervals`, where each interval is represented as `[start, end]`, combine all overlapping intervals and return an array of non-overlapping intervals that covers exactly the same ranges. Requirements and edge cases: - Intervals may be provided in any order. - Two intervals overlap if they share at least one point. For example, `[1, 4]` and `[4, 5]` should be combined into `[1, 5]`. - Return the intervals in increasing order by start value. Example: ```text Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] ``` ```text Input: intervals = [[1,4],[4,5]] Output: [[1,5]] ```

Quick Answer: This two-part question evaluates numeric digit-manipulation and interval-merging competencies, specifically integer palindrome detection (accounting for sign and integer limits) and combining overlapping ranges via sorting and range aggregation in the Coding & Algorithms domain.

Part 1: Check Whether an Integer Reads the Same Backward

Given an integer x, return True if its decimal representation reads the same from left to right and from right to left. Otherwise, return False. Negative integers are not palindromes because of the leading minus sign. Try to solve the problem using arithmetic operations instead of converting the integer to a string.

Constraints

  • -2^31 <= x <= 2^31 - 1
  • Negative integers must return False
  • An arithmetic-based solution is preferred over string conversion

Examples

Input: 121

Expected Output: True

Explanation: 121 reads the same forward and backward.

Input: -121

Expected Output: False

Explanation: Negative numbers are not palindromes.

Input: 10

Expected Output: False

Explanation: Reversed, 10 becomes 01, which is not equal to 10.

Input: 0

Expected Output: True

Explanation: 0 is the same when read from both directions.

Input: 12321

Expected Output: True

Explanation: The digits mirror around the center.

Hints

  1. A negative number can never be a palindrome because the minus sign only appears on the left.
  2. Try reversing only the second half of the digits instead of the whole number.

Part 2: Combine Overlapping Ranges

Given a list of intervals, where each interval is represented as [start, end], merge all overlapping intervals and return a new list of non-overlapping intervals that covers exactly the same ranges. Intervals may appear in any order. Two intervals overlap if they share at least one point, so [1, 4] and [4, 5] should be merged into [1, 5]. Return the result sorted by starting value.

Constraints

  • 0 <= len(intervals) <= 10^4
  • -10^9 <= start <= end <= 10^9
  • Intervals may be unsorted

Examples

Input: [[1, 3], [2, 6], [8, 10], [15, 18]]

Expected Output: [[1, 6], [8, 10], [15, 18]]

Explanation: The first two intervals overlap and merge into [1, 6].

Input: [[1, 4], [4, 5]]

Expected Output: [[1, 5]]

Explanation: The intervals share the point 4, so they overlap.

Input: []

Expected Output: []

Explanation: An empty input produces an empty result.

Input: [[5, 7]]

Expected Output: [[5, 7]]

Explanation: A single interval does not need merging.

Input: [[1, 4], [0, 2], [3, 5]]

Expected Output: [[0, 5]]

Explanation: After sorting, all three intervals connect through overlap and merge into one.

Hints

  1. Sort the intervals by their start value before trying to merge them.
  2. Keep track of the last interval in the output. If the next interval overlaps, extend the end; otherwise, start a new interval.
Last updated: May 19, 2026

Loading coding console...

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.

Related Coding Questions

  • Solve Flower Placement and Directory Deletion - Google (medium)
  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Implement Checksums and Feature Rollout Evaluation - Google (medium)