Freshworks Interview Question

First round: String based DSA problem (HARD)