Validate Typed CSV Records
Updated
Problem statement
Validate CSV records that have already been split into fields. columnTypes describes the columns in order, and required[i] says whether column i must be nonempty.
Each nonempty field must follow its declared type:
STRING: any printable ASCII string.INTEGER: an optional leading minus sign followed by one or more digits.DECIMAL: an optional leading minus sign, one or more digits, and an optional decimal point followed by one or more digits. Exponents are not accepted.BOOLEAN: exactlytrueorfalse.
A record is valid exactly when it has the same number of fields as columnTypes, every required field is nonempty, and every nonempty field matches its type. An empty optional field is valid without further type checking. Return one boolean per record in input order.
Function
validateCsvRecords(columnTypes: String[], required: boolean[], records: String[][]) → boolean[]Examples
Example 1
columnTypes = ["INTEGER","STRING","BOOLEAN"]required = [true,true,false]records = [["42","alice","true"],["-7","","false"],["1","bob",""],["3.5","eve","true"]]return = [true,false,true,false]The second record omits a required string. The third record may leave its optional boolean empty. The fourth record uses a decimal where an integer is required.
Example 2
columnTypes = ["DECIMAL","INTEGER"]required = [true,false]records = [["12.50","7"],["-3",""],[".5","2"],["1e3","4"],["5","2.0"]]return = [true,true,false,false,false]The first two records follow the grammar. A decimal must have a digit before the decimal point, exponent notation is unsupported, and 2.0 is not an integer.
Constraints
1 <= columnTypes.length == required.length <= 100.1 <= records.length <= 100000.- Every column type is
STRING,INTEGER,DECIMAL, orBOOLEAN. - Every field contains at most
100printable ASCII characters. - The total number of fields across all records is at most
200000. - Input fields are already decoded; CSV quoting and delimiter parsing are outside this exercise.
More Stripe Phone Screen questions
- Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
- Merchant Payout Reserve CalculatorPHONE SCREEN · Seen Nov 2026
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
- Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Reversible Run-Length EncodingZillow · PHONE SCREENZillow interview questions
- Format CSV Rows as an ASCII TableAmazon · PHONE SCREEN
- Correct Apartment Bedroom CountsRamp · OARamp interview questions
- Parse Command-Line TokensSamsara · ONSITE INTERVIEWSamsara interview questions
- Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Load/Store Arithmetic InterpreterJane Street · PHONE SCREENJane Street interview questions
- CSV Row SerializerMercor · PHONE SCREENMercor interview questions
Stripe interview experiences
- Stripe New Grad SWE OA and Phone Screen: 2 Experiences
- Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
- Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
- Stripe OA: What It Tests (2026)
- Stripe SWE Onsite over Two Days: 1 Experience
- Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences