This set of problems evaluates algorithmic problem-solving skills across selection and order-statistics, graph algorithms and traversals, connected-component analysis on irregular grids, optimization under exchange-rate transformations, and streaming data-structure design.
The interview note referenced several independent coding problems. Solve each one independently.
a
and
b
, each already sorted in non-decreasing order. Compute the median of the multiset formed by all elements in both arrays. The target solution should run in
O(log(min(len(a), len(b))))
time.
1.0
unit of an initial currency
S
. On day 1, you may perform any number of conversions using a set of exchange pairs and rates. On day 2, you may again perform any number of conversions using a different set of exchange pairs and rates. For each listed pair
(u, v)
with rate
r
, you may convert
u -> v
at rate
r
and
v -> u
at rate
1/r
. Determine the maximum amount of currency
S
you can end with after both days.
1
(house) or
0
(empty). Two houses are connected if they are adjacent vertically or horizontally and the neighboring cell actually exists in the ragged grid. For every connected component of houses, return its bounding box as
(min_row, min_col, max_row, max_col)
.
add(x)
: insert a number
median()
: return the median of all inserted numbers
Explain the expected time and space complexity for each problem.