title: Find Path with maximum value where T squares value can be doubled
body: <p>Given a square matrix of size N*N, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells which starts from top left cell move only right or down and ends on bottom right cell. We want to find the path with maximum value. Now to make things even more interesting: you also have T tokens. You can use the tokens to double the value on the current square. You can only use one token on any given square.</p>
  
  <p>This is how I have solved the first part of the problem.</p>
  
  <pre><code>public static long pathWithMaxCost(int[][] n, int tokens) {
      int[][] arr = new int[n.length][n[0].length];
  
      // starting position
      arr[arr.length - 1][0] = n[arr.length - 1][0];
  
      // first column
      for (int i = arr.length - 2; i &gt;= 0; i--) {
          arr[i][0] = arr[i + 1][0] + n[i][0];
      }
  
      // last row
      for (int i = 1; i &lt; arr[0].length; i++) {
          arr[arr.length - 1][i] = arr[arr.length - 1][i - 1] + n[arr.length - 1][i];
      }
  
      for (int i = arr.length - 2; i &gt;= 0; i--) {
          for (int j = 1; j &lt; arr[0].length; j++) {
              arr[i][j] = Math.max(arr[i][j - 1], arr[i + 1][j]) + n[i][j];
  
          }
      }
  
      return arr[0][arr[0].length - 1];
  }
  </code></pre>
  
  <p>Now how can I handle the token part, T square values can be doubled?</p>