Finastra Interview Question

Coding question on strings (counting and arranging)