|
|
back to boardI used dijkstra to do in O(mnlog(mn))? Whats your approach? I used dynamic programming to solve the question. dp[floor][room][lastStep] indicates the best way to reach top when we are on floor, room and the last step is know. Each state of dp is solved in constant time as we have to do only 2 computations at each step. But my approach runs very very slow. Two dimensions are enough DP can solve this problem in O(MN). |
|
|