Meta interview question

a variation of simplify path from leet code