JPMorganChase interview question

Questions about string and some simple greedy algorithm