Wildcard Address-Book Queries
Updated
Problem statement
Each address is a four-string row [streetNumber,street,city,state]. For every query with the same four fields, a field equal to * is a wildcard; every other field must match exactly.
Return one boolean per query indicating whether at least one stored address matches. Comparisons are case-sensitive.
Function
queryAddressBook(addresses: String[][], queries: String[][]) → boolean[]Examples
Example 1
addresses = [["1","Main","San Jose","CA"],["1","Main","Austin","TX"]]queries = [["1","Main","San Jose","CA"],["1","Main","San Jose","*"],["1","Main","*","*"],["22","Main","San Jose","CA"]]return = [true,true,true,false]This reproduces the four source query outcomes, with * representing None.
Example 2
addresses = [["10","Oak","Portland","OR"]]queries = [["*","*","*","*"],["10","Oak","Portland","WA"]]return = [true,false]The all-wildcard query matches any address; the wrong state does not.
Example 3
addresses = []queries = [["*","*","*","*"]]return = [false]No query matches an empty address book.
Constraints
0 <= addresses.length, queries.length <= 200000.- Every row contains exactly four nonempty strings; stored address fields never equal
*.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Find the Unpaired NumbersAdobe · PHONE SCREENAdobe interview questions
- Find the Unique Element Among PairsChubb · PHONE SCREENChubb interview questions
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
- Count Valid Bitwise PairsStripe · OAStripe interview questions
- Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
- Count Subarrays With Given XORInMobi · OAInMobi interview questions
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Palindrome-Rearrangeable PairsExpedia · OAExpedia interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW