Company: Texas

Difficulty: medium

Problem Statement

Bouncing Diagonal Robot Given an `r × c` integer matrix and a starting cell `(x, y)` (0-based), a robot starts by moving diagonally down-right. Add every visited cell value to the answer. Before a move that would leave the matrix, reverse that coordinate direction, then make the move. Stop immediately before revisiting a cell; the repeated cell is not added again. Input First line: `r c`. The next `r` lines contain the matrix. Last line: `x y`. Output Print the sum of visited values. Constraints `2 ≤ r, c ≤ 1000`; the start is not a corner; values fit signed 32-bit integers. Use 64-bit for the sum. Example Input: `3 3 / -12 33 -4 / 12 -1 15 / 49 -4 10 / 0 1` Output: `56`

More Texas OA questionsInterview experiences