Algorithm · Uber · Hard
You are given an integer matrix grid with m rows and n columns. From any cell you may step to one of its four orthogonal neighbors, but only if the neighbor's value is strictly larger than the value of the cell you are leaving. Every path begins at the top-left cell (0, 0). Build a data structure that answers repeated queries of the form: Each query must return some strictly increasing path that starts at (0, 0) and ends at a cell holding the value target, expressed as the…