Hello Devansh, my code may be wrong. But I have tested your given input and it worked for me. If you give a start and goal configuration which cannot be achieved then the code fails. I have not validated my code according to that.
You can visit this article to read about the issue: https://www.geeksforgeeks.org/check-instance-15-puzzle-solvable/