Company: Publicis Sapient_27sept
Difficulty: medium
Maximum Coins in a Grid Path Problem Description A newly released mobile game has players moving a token across a 2 x n grid (2 rows, n columns), where every cell starts out holding some number of coins. As the game clock advances, the coins sitting in a cell keep growing - at time t, the cell at position (i, j) holds t * coins[i][j] coins. A player must: Start from position (0, 0) at time t = 0 Move to a neighboring cell in one unit of time Visit each cell exactly once Collect all coins in visited cells Determine the maximum number of coins a player can collect. Examples Example 1: Input: n = 4 coins = [[1, 4, 3, 2], [2, 1, 3, 2]] One path that reaches the optimum, together with the coins picked up along the way based on the coins array above: Time (t) | Cell | coins[i][j] | Collected (t * coins[i][j]) ---------|--------|-------------|---------------------------- 0 | (0,0) | 1 | 0 * 1 = 0 1 | (1,0) | 2 | 1 * 2 = 2 2 | (1,1) | 1 | 2 * 1 = 2 3 | (0,1) | 4 | 3 * 4 = 12 4 | (0,2) | 3 | 4