Very straight thought of DP, goes well in Eclipse but stuck in submit


  • -1
    Q
    public static int minDis(String w1, String w2){
    
    	if(w1.equals("")||w1==null)
    		return w2.length();
    	if(w2.equals("")||w2==null)
    		return w1.length();
    	if(w1.charAt(w1.length()-1)==w2.charAt(w2.length()-1))
    		return minDis(w1.substring(0, w1.length()-1),w2.substring(0, w2.length()-1));
    	
    	return min(minDis(w1.substring(0, w1.length()-1),w2.substring(0, w2.length()-1))+1,
    			minDis(w1.substring(0, w1.length()-1),w2)+1,
    			minDis(w1,w2.substring(0,w2.length()-1))+1
    			);
    }
    
    public static int min(int s1, int s2, int s3){
    	return Math.min(s1, Math.min(s2, s3));
    }
    

    However, the report always says line 8: error: cannot find symbol: method minDis(String,String). When I try Run Code, given word1="", word2="", line 8 error as above but when I try in my Eclipse, it's never a problem. Anybody know what's wrong with my code? Thx!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.