public int minDistance(String word1, String word2) {
    		if(word1==null||word2==null){
    			return 0;
    		}
    		int len1=word1.length();
    		int len2=word2.length();
    		
    		int[][] matrix=new int[len1+1][len2+1];
    		for(int i=1;i<=len1;i++){
    			matrix[i][0]=i;
    		}
    		for(int j=1;j<=len2;j++){
    			matrix[0][j]=j;
    		}
    		
    		for(int i=1;i<=len1;i++){
    			char c1=word1.charAt(i-1);
    			for(int j=1;j<=len2;j++){
    				char c2=word2.charAt(j-1);
    				if(c1==c2){
    					matrix[i][j]=matrix[i-1][j-1];
    				}else{
    					int delete=matrix[i-1][j]+1;
    					int insert=matrix[i][j-1]+1;
    					int substitute=matrix[i-1][j-1]+1;
    					int minimum=delete;
    	                minimum = delete;
    	                if (insert < minimum) {
    	                    minimum = insert;
    	                }
    	                if (substitute < minimum) {
    	                    minimum = substitute;
    	                }
    	                matrix[i][j] = minimum;
    				}
    			}
    		}
        return matrix[len1][len2];
    }