FastPrepProject and Filter Structured Records
Problems/Project and Filter Structured Records

Project and Filter Structured Records

Stripe logoStripe● MediumFULLTIMENEW GRADPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes cumulative field projection and validated multi-condition filtering over structured records, but omits the exact schema, filter grammar, output shape, bounds, and third part. A later screenshot-backed new-grad sighting also says lowercase handling caused the key Part 2 bug, without preserving which comparison was intended. The judged core task matches the visible source at about 76%; its case-sensitive comparison remains a labeled practice choice rather than a recovered interview rule.

You are given a shared schema fieldNames and a collection of records. Each record is an array of string values aligned with the schema, so records[i][j] is the value of field fieldNames[j].

A projection request lists selectedFields. Each row of filters contains exactly two strings: a field name and its expected value. A record matches only when all filter conditions equal the corresponding record values using case-sensitive string equality.

First validate every name in selectedFields and every filter field name. If any name is absent from fieldNames, return exactly [["INVALID"]]. Otherwise, return one projected row for every matching record. Preserve record order, and place each row's values in selectedFields order. An empty filter list matches every record, while a valid request with no matching records returns an empty array.

Function

projectAndFilterRecords(fieldNames: String[], records: String[][], selectedFields: String[], filters: String[][]) → String[][]

Examples

Example 1

fieldNames = ["name","email","country","tier"]records = [["Ada","ada@example.com","US","pro"],["Ben","ben@example.com","CA","pro"],["Cy","cy@example.com","US","basic"]]selectedFields = ["name","email"]filters = [["country","US"],["tier","pro"]]return = [["Ada","ada@example.com"]]

Only Ada has both country = US and tier = pro. The returned row follows the requested name, then email, order.

Example 2

fieldNames = ["name","team"]records = [["Ana","risk"],["Bo","core"]]selectedFields = ["team","name"]filters = []return = [["risk","Ana"],["core","Bo"]]

With no filters, both records match. Input row order is preserved, and each row is projected into team, then name, order.

Example 3

fieldNames = ["name","team"]records = [["Ana","risk"]]selectedFields = ["name"]filters = [["country","US"]]return = [["INVALID"]]

The schema has no country field, so the whole request is invalid before any records are filtered.

Constraints

  • 1 <= fieldNames.length <= 100.
  • Every field name is a non-empty printable ASCII string of length at most 32, and fieldNames contains no duplicates.
  • 0 <= records.length <= 100000, and every record has exactly fieldNames.length values.
  • 1 <= selectedFields.length <= 100; its entries are distinct non-empty printable ASCII field names.
  • 0 <= filters.length <= 100, and every filter has exactly two strings: a non-empty printable ASCII field name and an expected value.
  • Each record value and expected value has at most 100 printable ASCII characters.
  • The total number of values across all records is at most 200000.
  • Field-name and value comparisons are case-sensitive.

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[][] projectAndFilterRecords(String[] fieldNames, String[][] records, String[] selectedFields, String[][] filters) {
        // Write your code here
    }
}
Checking account…