Facebook Onsite - ML Engineer

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-04-23Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

Let's say you have a list of pairs

(('1', 'a'), ('c', 'd'), ... ('10', '5')]

values in pair can be (character, character), (integer, character), (character, integer) but not (integer, integer), and the pair means the first element is STRICTLY smaller than the second element

(a, b) => a < b
(1, c) => 1 < c

and so on.

A character can be any arbitrary value satisfying the condition.

Given such a list, define a function that checks whether the list is valid or not. For instance,

[(a, b), (b, c)] is valid. However,

[(5, a), (a, b), (b, 5)] is invalid because 5<a, a<b, then b<5 is impossible.

Comments