Google Interview Question

Leetcode, one topological sort 1 string modification