FastPrepValidate Six-Column Business CSV Rows
Problems/Validate Six-Column Business CSV Rows

Validate Six-Column Business CSV Rows

Stripe logoStripe● MediumFULLTIMENEW GRADPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The visible source supplies the six-column format, header handling, four ordered rules, exact output labels, case-insensitive whitespace tokens, ignored words, and overlap threshold. This practice version preserves that deterministic contract. The judged core task matches the visible report at about 85%.

rows[0] is a six-column header. Validate every later comma-separated row and return one label per data row. Fields do not contain commas, quoting, or escapes.

Apply these rules in order and report only the first failure:

  1. RULE_1: exactly six trimmed fields, each nonempty.
  2. RULE_2: the trimmed fifth field has length from 5 through 31 inclusive.
  3. RULE_3: no whitespace token in the second field is a case-insensitive member of forbiddenWords.
  4. RULE_4: remove case-insensitive ignoreWords from the distinct lowercase whitespace tokens of field two. At least half of the remaining words, rounded up, must appear in the distinct lowercase non-ignored tokens of field four or field five. If no word remains from field two, this rule fails.

Return VALID or INVALID:RULE_X.

Function

validateBusinessRows(rows: String[], forbiddenWords: String[], ignoreWords: String[]) → String[]

Examples

Example 1

rows = ["id,name,type,description,code,status","1,Acme LLC,vendor,Acme services,12345,active","2,Bad Corp,vendor,Other,12345,active"]forbiddenWords = ["bad"]ignoreWords = ["llc","corp"]return = ["VALID","INVALID:RULE_3"]

The first row has an overlapping word after ignoring LLC; the second fails the forbidden-word rule first.

Example 2

rows = ["h1,h2,h3,h4,h5,h6","1,Alpha Beta,x,beta market,alpha,ok","1,Alpha Beta,x,none,alpha,ok","1,,x,a,12345,ok"]forbiddenWords = []ignoreWords = []return = ["VALID","VALID","INVALID:RULE_1"]

Rules are checked in order, and both valid rows meet the one-of-two overlap threshold.

Example 3

rows = ["a,b,c,d,e,f","1,LLC LLC,x,llc,llc12,ok"]forbiddenWords = []ignoreWords = ["llc"]return = ["INVALID:RULE_4"]

A second field with no non-ignored word fails rule four.

Constraints

  • 2 <= rows.length <= 100000.
  • The header has exactly six comma-separated fields.
  • Each row and word-list entry has at most 1000 characters.
  • The combined input length is at most 2 * 10^6.

More Stripe problems

  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
  • Chat Billing CalculationOA · Seen Nov 2026
  • Deployment Window SchedulerOA · Seen Nov 2026
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] validateBusinessRows(String[] rows, String[] forbiddenWords, String[] ignoreWords) {
        // Write your solution here.
    }
}
Checking account…