I used adjacency list instead of adjacency matrix to solve the problem.
It works for test cases i tried but gives run error when submitting. Can you please check the code once and tell me whats wrong, provide failing test cases if possible.
Snakes and Ladders Adjacency List Error
i think you are you have to minimise the cell , but you are just updating them once .
if(dis[i]==1000)
you should do is
dis[i]=min(dis[i],1+dis[top])
Why should i do this, this isn’t dijstra in bfs we dont need to do this. Plus my question wasnt regarding logic, i was getting run error (runtime) thats what i was asking. My code works for the sample inpits + few others that i have tried but doesnt work when submitting.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.