My code is giving the correct output for the sample input, and I can't seem to find what's wrong with it, please assist