PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Validate a simplified numeric string

Last updated: Mar 29, 2026

Quick Overview

This question evaluates string-parsing, formal-grammar validation, and edge-case reasoning competencies, including the ability to recognize valid numeric formats and to provide time and space complexity analysis.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Validate a simplified numeric string

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement isValidNumber (s) that returns true if and only if the ASCII string s represents a valid number under these simplified rules: - Optional leading '+' or '-'. - A mantissa that is either: (a) one or more digits, optionally containing a single decimal point anywhere (e.g., '123', '0.5', '.8', '10.'), with at least one digit overall; or (b) exactly a decimal point is not allowed ('.' invalid). - An optional exponent part: 'e' or 'E' followed by an optional '+' or '-' and then at least one digit (e.g., '1e9', '-3.2E-4'). - No spaces, commas, underscores, or other characters are allowed anywhere. - Leading zeros are allowed; multiple signs or multiple decimal points are not. Return false for cases like 'e3', '+.', '1.2.3', '--6', '6e', '6e-'. Provide time and space complexities and briefly justify your approach.

Quick Answer: This question evaluates string-parsing, formal-grammar validation, and edge-case reasoning competencies, including the ability to recognize valid numeric formats and to provide time and space complexity analysis.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Aug 12, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

Implement isValidNumber (s) that returns true if and only if the ASCII string s represents a valid number under these simplified rules:

  • Optional leading '+' or '-'.
  • A mantissa that is either: (a) one or more digits, optionally containing a single decimal point anywhere (e.g., '123', '0.5', '.8', '10.'), with at least one digit overall; or (b) exactly a decimal point is not allowed ('.' invalid).
  • An optional exponent part: 'e' or 'E' followed by an optional '+' or '-' and then at least one digit (e.g., '1e9', '-3.2E-4').
  • No spaces, commas, underscores, or other characters are allowed anywhere.
  • Leading zeros are allowed; multiple signs or multiple decimal points are not. Return false for cases like 'e3', '+.', '1.2.3', '--6', '6e', '6e-'. Provide time and space complexities and briefly justify your approach.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta 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.