Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Convert Strings to Numbers
00:00
5 left

Convert Strings to Numbers

MediumPython

Problem

Caesars Sportsbook receives wager amount fields as strings. Convert each string to a base-10 integer while preserving input order and handling malformed or out-of-range values safely.

Implement convert_number_strings(values, min_value, max_value). Trim surrounding whitespace, accept an optional leading + or -, and require at least one ASCII digit after the sign. Valid values within the inclusive range [min_value, max_value] become integers. Return None for empty strings, sign-only strings, strings containing non-digit characters, or values outside the range.

Do not use the built-in int() conversion for the main solution. The input list itself must not be modified.

Formal Specification

  • Input: values, a list of strings; min_value and max_value, integers where min_value <= max_value.
  • Output: A list containing either the parsed integer or None for each input string.
  • Whitespace is allowed only around the number, not between its sign and digits or between digits.

Constraints

  • 0 <= len(values) <= 10^4
  • 0 <= len(values[i]) <= 32
  • -10^9 <= min_value <= max_value <= 10^9
  • Only ASCII digits may appear after an optional leading sign
  • The input list must not be modified

Function Signature

def convert_number_strings(values, min_value, max_value):
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

Sign up free to run or submit. Log in
Code
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 2
Run your code to see test output here.