Accept Beat 79% Just Compare length?


  • 0
    L
    public class Solution {
        public int findLUSlength(String a, String b) {
           int aLength = a.length();
        	int bLength = b.length();
            if(aLength>bLength && a.contains(b)){
            	return aLength;
            }
            
            if(bLength>aLength && b.contains(a)){
            	return bLength;
            }
            
            else {
            	if(b.equals(a)){
            		return -1;
            	}else{
            	 return aLength>bLength?aLength:bLength;
            	}
            }
        }
    }
    

Log in to reply
 

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