Facebook | Phone Interview - Screening Round | UI Enterprise Engineer | London

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-01-07Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: UI Enterprise Engineer
Interview Stage: Phone Interview - Screening Round
Location: London
Year: unknown

Original Post Content:

Given two arrays items and excludes, write a function to filter items array using excludes items.

The filter function should take O(n) as time complexity.

Example:
const items = [ {type: "mobile", model: "iPhone", color:"silver"}, {type: "mobile", model: "iPhone", color:"grey"},{type: "mobile", model: "Samsung", color:"silver"},{type: "mobile", model: "Samsung", color:"blue"}, {type: "mobile", model: "LG", color:"silver"}, {type: "mobile", model: "LG", color:"gold"}]

const excludes= [ {k: "mobile", v: "LG"}, {k: "color", v:"silver"}]

output
const items = [ {type: "mobile", model: "iPhone", color:"grey"},{type: "mobile", model: "Samsung", color:"blue"}]

Comments