Graphs
111 / 170GraphsLesson 4 of 8About 72 min
When asking the question from each cell is expensive, ask the opposite question from the edges.
Water flows from a cell to a neighbor whose height is equal or lower. You want every cell from which water can reach the border. Searching outward from the border, what should the neighbor condition be?
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.