Part A — 2D array transforms: Given an m×n integer matrix, implement the following in-place operations with clear function boundaries and complexity:
(
-
swapRows(A, i, j) that swaps two row indices i and j;
(
-
swapCols(A, i, j) that swaps two column indices i and j;
(
-
reverseRowOrder(A) that reverses the order of rows (top↔bottom) and reverseColOrder(A) that reverses the order of columns (left↔right);
(
-
rotate90(A, direction) that rotates the matrix by 90 degrees in the specified direction (clockwise or counterclockwise), supporting both square and rectangular matrices (for rectangular, return a new matrix or explain constraints). Specify time and space complexities and any edge-case handling (e.g., empty matrix, single row/column). Part B — most-illuminated point: You are given a list of street lights as pairs (x, r) where x is the light’s coordinate on a 1D line and r is its illumination radius. Each light illuminates the interval [x − r, x + r]. Find the point on the line covered by the maximum number of lights; if multiple points achieve the same maximum coverage, return the smallest such coordinate. Describe and implement an algorithm with optimal time complexity, and analyze time and space.