Solve string grouping and tree right-view problems | TikTok Interview Question