left as 0 and right as the maximum possible height difference (10^6).left is less than or equal to right, perform the following steps:
a. Calculate mid as the average of left and right.
b. Use BFS to check if a path exists from the top-left cell to the bottom-right cell with an effort less than or equal to mid.
c. If such a path exists, update right to mid - 1; otherwise, update left to mid + 1.left as the minimum effort required.