Why my code is failing for three test cases?

can you plz describe wht you are doing with FillHd function ? I am not able to understand it in your code.