Nasdaq Interview Question

solve some problems in the code