TikTok Interview Question

remove redundant edge in a tree