Duolingo Interview Question

some question about string manipulation, probably leetcode easy to medium level