• + 0 comments

    Hi I tried with no more than a simple if else and I could, just my logic is kind of weird but works.

    public static String appendAndDelete(String s, String t, int k) {
        // Write your code here
            
            int uno = s.length();
            int dos = t.length();
            
            if (s.equals(t))
            {return "Yes";}
            else if (s.length()>t.length() & (uno -dos) > k ){
                
                return "No";
            }else if (s.length()<t.length() & (dos-uno) == k/2 & s.charAt(uno-1) == t.charAt(dos-1)){
                
                return "Yes";
            }
            else if (s.length()<t.length() & (dos-uno) < k){
                
                return "No";
            }
            else if (s.length()== t.length() & (uno/2) > k/2 ){
                
                return "No";
            }else if (s.charAt(0)!= t.charAt(0) && s.length()>k/2){
                return "No";
            }
            
            return "Yes";
    
        }
    
    }