Google interview question

Leetcode, one topological sort 1 string modification