title: Edit Distance between the words comparing between two Strings
body: <p>I have seen many resources from the internet but couldn't found the exact help. i am trying to figure out the edit distance between the two strings example:
  String a = "put return between paragraph gioo";
  String b = "put hello between line phone gio";
  here I am always comparing with String a with the other string so here the edit distance should be 4.
  I have done some code execution its comparing me with the each character in the string.</p>
  
  <pre><code>                           int len1 = row10.length();
                              int len2 = row01.length();
                              int[][] dp = new int[len1 + 1][len2 + 1];
  
                              for (int i = 0; i &lt;= len1; i++) {
                                  dp[i][0] = i;
                              }
  
                              for (int j = 0; j &lt;= len2; j++) {
                                  dp[0][j] = j;
                              }
  
                              for (int i = 0; i &lt; len1; i++) {
                                  char c1 = row10.charAt(i);
                                  for (int j = 0; j &lt; len2; j++) {
                                      char c2 = row01.charAt(j);
                                      if (c1 == c2) {
                                          dp[i + 1][j + 1] = dp[i][j];
                                      } else {
                                          int replace = dp[i][j] + 1;
                                          int insert = dp[i][j + 1] + 1;
                                          int delete = dp[i + 1][j] + 1;
                                          int min = replace &gt; insert ? insert : replace;
                                          min = delete &gt; min ? min : delete;
                                          dp[i + 1][j + 1] = min;
                                      }
                                  }
                              }
                              System.out.println(dp[len1][len2]);
  </code></pre>