Uber Interview Question

Medium LC question (2D matrix)