Facebook phone interview

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-10-14Added By Anonymous
Source: Link

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

Original Post Content:

2 questions:

1. Find all permutations of string: simple recursive rotation - took only a few minutes to complete

2. Given a NxN map with walls and gates, calculate the minimal distance from all other cells to gate
Spent majority of the time on this (about 25~30min)

Idea was:
1. Locate all gates, then spawn agents - which counts distance and records previous location
2. For each agent: find all possible direction (minus where it came from)
3. If more than 1 direction available, spawn new agent to that direction
4. min(count++, any assigned value) for new location
5. agent is destroyed when: no where to go, or doesn't change distance of cell
6. iterate while n(agents)>0

Seemed to work but couldn't answer time complexity

Comments