Last Day Where You Can Still Cross
Explore how to use union find data structures to find the last day you can cross a matrix from top to bottom as cells turn to water. Understand the problem constraints, movement rules, and implement a solution to efficiently track connectivity over time.
We'll cover the following...
Statement
You are given two integers, rows and cols, which represent the number of rows and columns in a
Initially, on day 0, the whole matrix will just be all 0s, that is, all land. With each passing day, one of the cells of this matrix will get flooded and, therefore, will change to water, that is, from to . This continues until the entire matrix is flooded. You are given a 1-based array, waterCells, that records which cell will be flooded on each day. Each element ...