This question pair evaluates proficiency in fundamental algorithmic techniques: finding shortest paths in a grid via breadth-first search and applying dynamic programming on trees to maximize a sum under adjacency constraints, assessing graph traversal, state management, optimal substructure recognition, and complexity handling.

You are given a 2D grid representing a maze:
grid[r][c]
is either
'.'
(open cell) or
'#'
(wall).
S = (sr, sc)
and an end coordinate
E = (er, ec)
.
Task: Return the minimum number of steps from S to E. If E is unreachable, return -1.
Input (conceptual): grid, S, E
Output: minimum steps as an integer
Constraints (typical):
1 <= rows, cols <= 2000
(assume potentially large)
You are given the root of a binary tree where each node has an integer value (can be 0 or positive).
You want to select a set of nodes to maximize the sum of their values subject to the constraint:
Task: Return the maximum achievable sum.
Input (conceptual): root of a binary tree
Output: maximum sum as an integer
Constraints (typical):
10^5
10^4