The code seems correct and giving the expected output but while submitting it is giving compilation error.