My none recursive solution
Hello, I've finish this problem without recursion. Any comment on how i can improve on the code?   Thanks. \nIs there a reason why people are doing recursive bu
Hello, I've finish this problem without recursion. Any comment on how i can improve on the code?   Thanks. \nIs there a reason why people are doing recursive builds? (Space vs time?)\n\n\n    public class Solution {\n            public int minDistance(String word1, String word2) {\n                int [][] result = new int[word1.length()+1][word2.length()+1];\n                //set up deletion into null string;\n                for(int i=0;i<=word1.length();i++) result[i][0]=i;\n                for(int j=0;j<=word2.length();j++) result[0][j]=j;\n                for(int i=1;i<=word1.length();i++)\n                {\n                    for(int j=1;j<=word2.length();j++)\n                    {\n                        int del = result[i-1][j] +1;\n                        int ins = result[i][j-1] +1;\n                        int rep = result[i-1][j-1];\n                        if(word1.charAt(i-1)!=word2.charAt(j-1)) \n                        {\n                            rep+=1;\n                        }\n                        int min = Math.min(del,ins);\n                        min = Math.min(min,rep);\n                        result[i][j]=min;\n                    }\n                }\n                return result[word1.length()][word2.length()];\n            }\n        }
[]