PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates string manipulation and numeric representation skills, specifically handling decimal-point addition with arbitrary precision and reasoning about palindrome/permutation properties.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Handle palindrome & decimal addition

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

##### Question LeetCode 266. Palindrome Permutation Given two non-negative decimal number strings, implement addition that supports a decimal point. https://leetcode.com/problems/palindrome-permutation/description/

Quick Answer: This question evaluates string manipulation and numeric representation skills, specifically handling decimal-point addition with arbitrary precision and reasoning about palindrome/permutation properties.

Given two non-negative decimal number strings a and b, return their sum as a normalized decimal string. The strings may contain at most one decimal point. Perform digit-wise addition; do not parse the entire strings as numeric types. Normalization rules for the output: remove leading zeros in the integer part (but keep a single '0' if the number is zero), remove trailing zeros in the fractional part, and omit the decimal point if the fractional part becomes empty.

Constraints

  • 1 <= len(a), len(b) <= 100000
  • a and b contain only digits and at most one '.'
  • If '.' is present, there is at least one digit on both sides (matches regex: ^[0-9]+(\.[0-9]+)?$)
  • No signs, spaces, or exponent notation
  • Must not convert the entire strings to integers/floats/decimals; use digit-wise addition
  • Return must be normalized as described

Examples

Input:

Expected Output: 13

Input:

Expected Output: 1000

Input:

Expected Output: 16

Input:

Expected Output: 0

Input:

Expected Output: 579.789

Input:

Expected Output: 0

Input:

Expected Output: 1.24

Input:

Expected Output: 1000

Hints

  1. Split each input around the decimal point into integer and fractional parts.
  2. Pad the shorter fractional part with trailing zeros so both fractions have equal length.
  3. Add fractional parts right-to-left, carrying into the integer part if needed.
  4. Add integer parts right-to-left, including any carry from the fractional sum.
  5. Trim trailing zeros from the fractional result and leading zeros from the integer result; remove the decimal point if the fractional part becomes empty.
Last updated: Mar 29, 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
  • AI Coding 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

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)