Matrix Traversal

Problem Overview

  • Find a path in a 4x4 matrix from any first-row cell to the last row that maximizes remaining energy from an initial 100.
  • Moves go to the next row: down-left, down, or down-right; stepping on a cell subtracts mat[i][j]; final energy can be negative.
  • Input: int mat[4][4], 0 <= mat[i][j] < 100; Output: int max remaining energy.
  • Domain: grid traversal and energy cost optimization for routing/resource planning.
  • A Flexport coding interview problem and common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: