Product Record Search
Updated
Problem statement
You are given a product catalog as three arrays that line up by position: productNames[i], prices[i], and productionYears[i] describe product i.
You also get a list of exact-match queries. Query i looks in the field queryFields[i], which is name, price, or year, for the string queryValues[i].
- For
name, compare the value with the product names as it is. - For
priceandyear, read the value as a base-10 integer first.
No two products share a name, a price, or a production year. For each query, in order, return the name of the matching product, or the empty string if no product matches.
Build a sorted index for each of the three fields, and answer each query with binary search.
Function
searchProductRecords(productNames: String[], prices: int[], productionYears: int[], queryFields: String[], queryValues: String[]) → String[]Examples
Example 1
productNames = ["laptop","mouse","phone"]prices = [1200,25,800]productionYears = [2022,2024,2023]queryFields = ["name","price","year","price"]queryValues = ["mouse","800","2022","999"]return = ["mouse","phone","laptop",""]The name query finds mouse. The price query finds phone, and the year query finds laptop. No product costs 999, so the last answer is the empty string.
Example 2
productNames = ["book","camera"]prices = [15,500]productionYears = [2020,2021]queryFields = ["year","name","price"]queryValues = ["2021","book","15"]return = ["camera","book","book"]The year query finds camera. The name query and the price query both find book, so the same product can match more than once. The answer lists book twice.
Example 3
productNames = ["desk","lamp","monitor"]prices = [300,40,250]productionYears = [2019,2020,2021]queryFields = ["name","year","price"]queryValues = ["chair","2025","1"]return = ["","",""]No product is named chair, and no product has the queried year or price. All three answers are the empty string.
Constraints
1 <= productNames.length <= 2 * 10^5.productNames.length == prices.length == productionYears.length.- Product names are distinct lowercase identifiers of length 1 through 30.
1 <= prices[i] <= 10^9, and prices are distinct.1900 <= productionYears[i] <= 2100, and production years are distinct.1 <= queryFields.length == queryValues.length <= 2 * 10^5.- Every query field is
name,price, oryear. Numeric query values are written in standard base-10 form.
More Wells Fargo Online Assessment questions
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
- Longest Subsequence That Is a SubstringOA · Seen Jul 2026
- Overloaded Game Account InventoriesOA · Seen Jul 2026
- Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
Similar questions at other companies
- Find the Words for Each PrefixDocuSign · PHONE SCREENDocuSign interview questions
- Find Unmet Users With Shared InterestsPalantir · ONSITE INTERVIEWPalantir interview questions
- Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Count Proper Prefix MatchesAT&T · OAAT&T interview questions
- Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Find Sum of BeautiesAmazon · OA
- Choose ContainersIMC Trading · OAIMC Trading interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions