You are given three independent coding tasks.
Given an m x n grid maze where 0 means empty and 1 means wall, a ball starts at start = (sr, sc) and wants to reach destination = (dr, dc).
Movement rule: from any cell, you may choose one of 4 directions (up/down/left/right). The ball then rolls in that direction until the next step would hit a wall or go out of bounds; it stops at the last valid empty cell before the obstacle. You may then choose a new direction.
Return whether the ball can stop exactly at destination.
Input: maze: int[m][n], start: int[2], destination: int[2]
Output: bool
Constraints (typical): 1 ≤ m,n ≤ 100, maze[i][j] ∈ {0,1}, start/destination are empty.
Given the root of a binary tree, compute its diameter, defined as the maximum number of edges on any path between two nodes in the tree.
Input: root (binary tree)
Output: int
There are n single-threaded functions labeled 0..n-1. You are given a list of logs in chronological order.
Each log is a string in the format:
"id:start:timestamp"
or
"id:end:timestamp"
Rules:
end:timestamp
is
inclusive
(i.e., the function runs through that timestamp).
Return an array ans where ans[i] is the exclusive time spent in function i.
Input: n: int, logs: string[]
Output: int[]
Constraints (typical): 1 ≤ n ≤ 100, 1 ≤ logs.length ≤ 10^4, timestamps are non-decreasing integers.