Last updated
Was this helpful?
Last updated
Was this helpful?
ๅณไฝฟไธญ้ๅคไบไธๅ ๏ผก 2.5, 0.4 ๅจไธไธ่ผชไป็ถๅฏไปฅ update ๆ2.9
ไฝๅฆๆๆฏๆดๅทฎ็็ตๆ, seattle: 3 ไธ้่ฆๆดๆฐ
create an effort matrix stores effort record
create PriorityQueue accept int[] : new_dist(effort), row, col, order by effort (minHeap)
while PriorityQueue is not empty
poll node data from PriorityQueue (the smallest dist and row, col index)
if dist > effort[row][col] โ skip this round
if row & col == last cell โ return result
search this node's all neighbors, find new dist โ new smaller effort
if find new dist < effort[new_row][new_col] โ update effort[new_row][new_col] = new dist, and offer new smaller dist into PriorityQueue