Meta interview question

1 leet code medium question