• + 7 comments

    Yor explanation is hard to understand, check a look at me code. I think it easy to understand

    function isItPossibleToModify($s, $t, $k) {
        $sLength = strlen($s);
        $tLength = strlen($t);
    
        if ($sLength < $tLength) {
            return ($tLength - $sLength) % 2 == 0;
        }
    
        $commonPrefix = 0;
    
        // find a largest common prefix between s and t
        for ($i = 0; $i < min($sLength, $tLength); $i++) {
            if ($s[$i] != $t[$i]) {
                break;
            }
    
            $commonPrefix++;
        }
    
        $needToProcess = ($tLength - $commonPrefix) + ($sLength - $commonPrefix);
    
        return $needToProcess <= $k;
    }