Validate Numeric Fields During Bulk Profile CSV Imports

Last updated: November 29, 2026

Quick Overview

Write a function that returns whether a string is a valid decimal number for an import pipeline: optional surrounding spaces, optional sign, digits with at most one decimal point and at least one digit, and an optional exponent (e or E, optional sign, at least one digit).

LinkedIn
Coding & Algorithms
Software Engineer
LinkedIn
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Write a function that returns whether a string is a valid decimal number for an import pipeline: optional surrounding spaces, optional sign, digits with at most one decimal point and at least one digit, and an optional exponent (e or E, optional sign, at least one digit).

Recruiter and Sales Navigator bulk uploads accept CSVs with salary and count fields, and LinkedIn interviewers have long liked this validation problem. They watch whether you enumerate the grammar first and avoid a tangle of special cases.

What the Interviewer Expects
  • Writes down the grammar before coding
  • Tracks seen_digit, seen_dot, seen_exp flags in one pass
  • Requires at least one digit before and after the exponent
  • Rejects a sign anywhere except the start or right after e
  • Tests tricky inputs such as '.', 'e3', '1e', '+.8', '-1E-7'
Key Topics to Cover
string parsing
finite state machine
input validation
grammar
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you extend this to accept thousands separators like 1,000?
  • How would you express the grammar as a regex, and what are the risks?
  • How would you report the column and reason for a rejected value?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Valid: "2", " 0.1 ", "-.9", "4.", "2e10", "-1E-7", "+3.14". Invalid: ".", "e3", "1e", "--6", "1e2.5", "9a", "". Leading and trailing spaces are trimmed; internal spaces are...

High-Level Design

Grammar: [sign] (digits [. [digits]] | . digits) [(e|E) [sign] digits]. Implement it as a single scan with flags. A digit sets seen_digit. A dot is legal only before any dot and before any exponen...


Submit Your Answer
Markdown supported