You are given two independent coding tasks.
Given the root of a binary tree, return the in-order traversal of its node values.
root
(may be
null
)
Given an m x n matrix A of integers and coordinates (x, y) (0-indexed), compute the sum of all elements in the rectangle from (0,0) to (x,y) inclusive.
Example: sum(x,y) = Σ_{i=0..x} Σ_{j=0..y} A[i][j]
A
, and one or more queries
(x, y)
where
0 ≤ x < m
,
0 ≤ y < n
m,n
up to ~10^3 or higher; values can be negative; sums may require 64-bit integer type.