Given a city grid of open roads, blocked roads 'X' and DashMarts 'D' and a list of [row, col] locations, return each location's distance to its closest DashMart (-1 if unreachable or out of bounds). Asked in the assessment stage.
Implement get_closest_dashmart(grid, locations). grid is a list of equal-length strings containing O, X, and D; movement is up, down, left, or right. Return one integer per location. For grid = ["OOD", "OXO"] and locations = [[0, 0], [1, 1]], return [2, -1]. For grid = ["DOD"] and locations = [[0, 1]], return [1].
Constraints: 1 <= rows * columns <= 10^5, 1 <= len(locations) <= 10^4, and coordinates may be outside the grid.
O, X, or Ddef get_closest_dashmart(grid, locations):