Bloomberg Interview Question

one problem was about string manipulation, the other on heap