JPMorganChase Interview Question

Leet code - beautiful string problem