Solve Topological Sort and Anagram Indices | TikTok Interview Question