X interview question

LC Easy/medium array problem and some string manipulation