FastPrepFilter Formatted Records by Criteria
Problems/Filter Formatted Records by Criteria

Filter Formatted Records by Criteria

Zillow logoZillow● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Asked at Zillow in 2023, in two reports. A Senior Software Engineer II candidate had it in a technical round before the final interviews, which were then cancelled. A software developer candidate had it in a technical interview that came after a call with a recruiter and also covered past work and a database question. Neither report calls it a phone screen. We list it under phone screens as our reading, since neither interview is described as a final round.

In both processes the recruiter promised a coding task unlike a typical puzzle-style question. Both reports describe the same task: take several strings that hold formatted data, work out the values in them, and keep only the entries that pass some given conditions. One report rates it easy and says the interviewer was looking for general programming skill and for whether the candidate could build a fairly simple system.

Neither report says how a string is laid out, which conditions are used or how they are written, or what the answer looks like. Here the function gets the records and the conditions as two arrays of strings: each record is name:value fields joined by commas, and each condition, such as price<=500000, compares one field with a value. A record must pass every condition, and the function returns the passing records unchanged and in their original order. Values are lowercase words or whole numbers from 0 to 10^9; numbers are compared as numbers, words only with = and !=, and a record without the named field fails that condition. The examples use home listing fields such as city and price; that theme is ours. The limits (1 to 1,000 records of up to 100 characters, 1 to 10 conditions of up to 32 characters) are ours too, since no report gives any.

Our version is about 40% the same as the reported question.

You are given a list of records, each stored as one string, and a list of criteria. Return the records that meet every criterion.

A record is one or more fields joined by commas, and each field is written name:value, for example "city:seattle,price:450000,beds:3". A record never repeats a field name, and different records may have different fields.

A criterion is a field name, an operator and a value written together with no spaces, for example "price<=500000" or "city!=tacoma". The operator is one of =, !=, <, <=, > and >=. A record meets a criterion when it has a field with that name and comparing the field's value with the criterion's value using the operator gives true. Integer values are compared as numbers. A record that has no field with that name does not meet the criterion, whatever the operator.

Return the records that meet every criterion, exactly as written and in their original order. If no record does, return an empty array.

Function

filterRecords(records: String[], criteria: String[]) → String[]

Examples

Example 1

records = ["city:seattle,price:450000,beds:3","city:tacoma,price:380000,beds:4","city:seattle,price:720000,beds:4","city:seattle,price:500000,beds:2"]criteria = ["city=seattle","price<=500000"]return = ["city:seattle,price:450000,beds:3","city:seattle,price:500000,beds:2"]

The first and the last record have city equal to seattle and a price of at most 500000. The last one passes with a price of exactly 500000, because <= also accepts an equal value. The second record is in tacoma, and the third costs 720000.

Example 2

records = ["id:7,status:sold","id:12","id:31,status:active","id:40,status:pending"]criteria = ["status!=sold"]return = ["id:31,status:active","id:40,status:pending"]

"id:31,status:active" and "id:40,status:pending" have a status other than sold. "id:12" has no status field, so it does not meet the criterion, even though the operator is !=.

Example 3

records = ["beds:10,baths:2","beds:9,baths:3","beds:12,baths:1"]criteria = ["beds>9","baths>=2"]return = ["beds:10,baths:2"]

As numbers, 10 and 12 are greater than 9, and 9 is not. Of those two records, only "beds:10,baths:2" has at least 2 baths. Comparing the values as text would go wrong here: the text "10" sorts before "9".

Example 4

records = ["city:reno,price:200000","city:boise,price:310000"]criteria = ["price>=100000","pool=yes"]return = []

Both records meet price>=100000, but neither has a pool field, so neither meets pool=yes. The answer is empty.

Constraints

  • 1 <= records.length <= 1000
  • 3 <= records[i].length <= 100
  • 1 <= criteria.length <= 10
  • 3 <= criteria[j].length <= 32
  • Each records[i] is one or more name:value fields joined by commas, with no spaces, and no field name appears twice in the same record.
  • Each criteria[j] is a field name, then one of the operators =, !=, <, <=, >, >=, then a value, with no spaces.
  • A field name is 1 to 10 lowercase English letters. A value is either a word of 1 to 20 lowercase English letters or an integer from 0 to 10^9 written without leading zeros.
  • A field name holds the same kind of value (always an integer or always a word) in every record that has it, and a criterion on that name uses a value of the same kind. Criteria with <, <=, > or >= always use an integer.

More Zillow Phone Screen questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Jump GamePHONE SCREEN · Seen Dec 2022
  • Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
  • Employee Free TimePHONE SCREEN · Seen Oct 2022
  • First Unique Character in a StringPHONE SCREEN · Seen Oct 2022
  • K-th Smallest Number in a StreamPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Detect a Straight FlushTemu · PHONE SCREEN
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREEN
  • Single-Condition Product FilterCrowdstrike · PHONE SCREEN
  • Convert an Entry List to a MapEPAM · PHONE SCREEN
  • Most Frequent NameAmazon · PHONE SCREEN
  • Words with Repeated AnagramsThe Voleon Group · PHONE SCREEN
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Product Keyword SearchTesco · PHONE SCREEN
  • Verify Words Sorted by a Custom AlphabetTrueFoundry · PHONE SCREEN
  • Character Frequencies Across Nested String ListsSnowflake · PHONE SCREEN
See Zillow hiring insights
Saved
class Solution {
    public String[] filterRecords(String[] records, String[] criteria) {
        // Write your code here.
    }
}
Checking account…