I am trying to figure out the time complexity of this code https://leetcode.com/submissions/detail/816740998/ for this problem on leetcode https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/ . Since after each update we are pushing the node to the queue again I am not able to convince myself that the time complexity is O(nm). How can we prove that each cell will be updated constant times?