FastPrepBest Meeting Point
Problems/Best Meeting Point

Best Meeting Point

Walmart logoWalmart● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the well-known Best Meeting Point problem but leaves out the function signature, examples, and limits. Our version is about 95% the same as the reported question.

You are given a rectangular binary grid. Each cell containing 1 is a home, and each cell containing 0 is empty.

Choose any grid cell as a meeting point. A person at (r, c) travels to (x, y) with Manhattan distance |r - x| + |c - y|.

Return the minimum possible sum of travel distances from every home to one meeting point.

Function

minTotalDistance(grid: int[][]) → int

Examples

Example 1

grid = [[1,0,0,0,1],[0,0,0,0,0],[0,0,1,0,0]]return = 6
grid
01234010001100000200100

Meeting at row 0, column 2 gives distances 2, 2, and 2.

Example 2

grid = [[1,1]]return = 1
grid
01011

Either cell is an optimal meeting point.

Constraints

  • 1 <= grid.length, grid[0].length <= 200.
  • Every cell is 0 or 1.
  • The grid contains at least one home.

More Walmart Online Assessment questions

  • Largest Team Where Every Pair OverlapsOA · Seen Nov 2026
  • House RobberOA · Seen Sep 2026
  • Maximum Points by Deleting ElementsOA · Seen Sep 2026
  • Distinct Bitwise-OR Scores of Increasing SubsequencesOA · Seen Sep 2026
  • Minimum Cost to Make Array EqualOA · Seen Sep 2026
  • Minimum Stress PathOA · Seen Aug 2026
  • K-Capable Model CostsOA · Seen Jun 2026
  • K-Capable Model SelectionOA · Seen Jun 2026
  • Minimum Moves to Equal Candy BarsOA · Seen Oct 2024
  • Find Length of Longest Good SubsequenceOA · Seen Feb 2024

Similar questions at other companies

  • Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Maximum Points in a Perimeter-Bounded RectangleAmerican Express · OAAmerican Express interview questions
  • Minimum Euclidean Distance Between PointsLuma AI · OALuma AI interview questions
  • Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions
  • HTTP Request RedirectionAmazon · OA
  • Closest Pair of PointsCitadel · PHONE SCREENCitadel interview questions
  • Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions
  • Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • K Closest Points to a TargetAsana · ONSITE INTERVIEW
All Walmart interview questionsSee Walmart hiring insights
Saved
class Solution {
    public int minTotalDistance(int[][] grid) {
        // write your code here
    }
}
Checking account…