T-Mobile interview question

leetcode m to hard question