Tap here to switch tabs
Problem
Submissions

Problem: Minimum XOR Path in a Grid

Try to solve the Minimum XOR Path in a Grid problem.

Statement

Given an mimesnm imes n integer matrix grid, you begin at the top left cell (0,0)(0, 0) and want to reach the bottom right cell (m−1,n−1)(m - 1, n - 1). From any given cell, you may only move either right or down to an adjacent cell.

The score of a path is the bitwise XOR sum of all elements visited along the path, including the starting and ending cells.

Return the minimum possible XOR score among all valid paths from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1).

Constraints:

  • 1≤m=1 \leq m = grid.length ≤1000\leq 1000

  • 1≤n=1 \leq n = grid[i].length ≤1000\leq 1000

  • m * n ≤1000\leq 1000

  • 0≤0 \leq grid[i][j] ≤1023\leq 1023

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum XOR Path in a Grid

Try to solve the Minimum XOR Path in a Grid problem.

Statement

Given an mimesnm imes n integer matrix grid, you begin at the top left cell (0,0)(0, 0) and want to reach the bottom right cell (m−1,n−1)(m - 1, n - 1). From any given cell, you may only move either right or down to an adjacent cell.

The score of a path is the bitwise XOR sum of all elements visited along the path, including the starting and ending cells.

Return the minimum possible XOR score among all valid paths from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1).

Constraints:

  • 1≤m=1 \leq m = grid.length ≤1000\leq 1000

  • 1≤n=1 \leq n = grid[i].length ≤1000\leq 1000

  • m * n ≤1000\leq 1000

  • 0≤0 \leq grid[i][j] ≤1023\leq 1023