title: Finding max path in a maze skipping 2 cells
body: <p><a href="https://i.stack.imgur.com/O5bMY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O5bMY.png" alt="enter image description here" /></a></p>
  <p>Finding max path from (0,0) to (5,7) skips cells 1,5 and 2,5. Can anyone explain why? I get 3 different paths, but not the max path which the question needs.</p>
  <pre><code>int visited[10][10];
  int max_len=0;
  void max_path(int a[][10],int x,int y,int x1,int y1,int value=0){
      if(x==x1 &amp;&amp; y==y1){
          if(max_len&lt;value)
              max_len=value;
      }
  
      else{
          if(x+1&lt;10 &amp;&amp; !visited[x+1][y] &amp;&amp; a[x+1][y]!=0){
              visited[x][y]=1;
              max_path(a,x+1,y,x1,y1,value+1);
              visited[x][y]=0;
          }
  
          if(y+1&lt;10 &amp;&amp; !visited[x][y+1] &amp;&amp; a[x][y+1]!=0){
              visited[x][y]=1;
              max_path(a,x,y+1,x1,y1,value+1);
              visited[x][y]=0;
          }
  
          if(y-1&gt;=0 &amp;&amp; !visited[x][y-1] &amp;&amp; a[x][y-1]!=0){
              visited[x][y]=1;
              max_path(a,x,y-1,x1,y1,value+1);
              visited[x][y]=0;
          }
  
          if(x-1&gt;=0 &amp;&amp; !visited[x-1][y] &amp;&amp; a[x-1][y]!=0){
              visited[x][y]=1;
              max_path(a,x-1,y,x1,y1,value+1);
              visited[x-1][y]=0;
          }
      }
  }
  </code></pre>