FAANG Onsite - coding question
Anonymous User
435

I had received this question in a coding question for Thumbtack. Does anyone have optimized solution? I could only finish till 2nd requirement.

"2 BR | 2 BA | 777 Brockton Avenue, Abington MA 23501",
"3 BR | 1.5 BA | 30 Memorial Drive, Avon MA 23922",
"1 BR | 1 BA | 250 Hartford Avenue, Bellingham MA 20019",
"4 BR | 1 BA | 700 Oak Street, Brockton MA 23601",
"2 BR | 1 BA | 66-4 Parkhurst Rd, Chelmsford MA 18124",
"4 BR | 2 BA | 591 Memorial Dr, Chicopee MA 10240",
"1 BR | 1 BA | 121 Worcester Rd, Framingham MA 17001",
"2 BR | 2 BA | 301 Massachusetts Ave, Lunenburg MA 19462",
"3 BR | 2 BA | 501 Cambridge Ave, Lunenburg MA 19462"
]


Given an array of raw listing data as shown above, implement the following requirements:

REQUIREMENT 1:
Create a model class definition for a Listing based on the data shown above. bedrooms (double), bathrooms (double), address (string).

REQUIREMENT 2:
Parse the array shown above into Listing objects. The output of this algorithm is an array of listing objects (based on the class definition of a Listing from step 1).

REQUIREMENT 3:
Implement a search function that uses the array of listing objects from req 1 as the data source. The search function should allow users to search based on bedrooms, bathrooms and address. The output of this   is an array of listing objects that match the criteria. Here are some example queries:

Sample Test cases:
(bedrooms: "2+", bathrooms: "1+") -> Returns an array of listings that have more than 2 bedrooms and more than 1 bathroom in any address.

(bedrooms: "3+") -> Returns an array of listings that have more than 3 bedrooms and any number of bathrooms in any address.

(bathrooms: "2", address: "Chicopee") -> Returns an array of listings that have any number of bedrooms and exactly 2 bedrooms in Chicopee.
 */
Comments (1)