title: longest common subsequence function does not work for all examples
body: <p><strong>EDIT</strong>: UP</p>
  
  <p>The code does not work properly with the strings below.</p>
  
  <pre><code>"1 11 23 1 18 9 15 23 5"
  
  "11 1 18 1 20 5 11 1"
  </code></pre>
  
  <p><strong>EDIT</strong>: I noticed, that if I change 20 to 40 in second string, the function works properly...</p>
  
  <p>For strings:</p>
  
  <pre><code>"12 4 55 11 8 43 22 90 5 88 15"
  
  "15 66 4 36 43 22 78 88 32"
  </code></pre>
  
  <p>it works properly. Where is the problem? </p>
  
  <p>Here is my code:</p>
  
  <pre><code> int[][] tabelka = new int[linia1.length()+1][linia2.length()+1];
  
  
          for (int i = 0; i&lt;linia1.length(); i++) {
              for (j = 0; j&lt;linia2.length(); j++) {
  
                  if ( linia1.charAt(i) == linia2.charAt(j) ) {
                      tabelka[i+1][j+1] = tabelka[i][j] + 1;
                  }
  
                  else {
                      tabelka[i+1][j+1] = Math.max(tabelka[i+1][j], tabelka[i][j+1]);
                  }
  
              }
          }
  
          for (int i = 0; i&lt;linia1.length(); i++) {
              for (j = 0; j&lt;linia2.length(); j++) {
                  System.out.println(tabelka[i][j]);
              }
          }
  
          StringBuffer podciag = new StringBuffer();
  
          for(int x = linia1.length(), y = linia2.length(); x != 0 &amp;&amp; y != 0; ) {
  
              if( tabelka[x][y] == tabelka[x-1][y] ) {
                  licznik++;
                  x--;
              }
  
              else if( tabelka[x][y] == tabelka[x][y-1] ) {
                  licznik++;
                  y--;
              }
  
              else {
                  licznik++;
                  assert linia1.charAt(x-1) == linia2.charAt(y-1);
                  podciag.append(linia1.charAt(x-1));
                  x--;
                  y--;
              }
          }
  
          String buff = podciag.reverse().toString();
  </code></pre>
  
  <p>The output of this code (for the first two strings) is:</p>
  
  <pre><code>11 1 18 1 2 5
  </code></pre>
  
  <p>However, the output should be:</p>
  
  <pre><code>11 1 18 5
  </code></pre>