Sort by

recency

|

1446 Discussions

|

  • + 0 comments

    if i´m not mistaken these tests are wrong, please if i'm wrong help me to understand my mistake

            Input (stdin):                    s:abcd, t:abcdert, k:10
            Expected Output:            No
    
            I think having k = 3 here is enough so the out put should be Yes
    
            Input (stdin):                  s:y, t:yu,  k = 2
            Expected Output:         No
            having  k = 1 is enough and the output should be Yes
    
  • + 0 comments

    Thing is, you need to use exactly k moves, no more, no less. Else, fail.

    string appendAndDelete(string s, string t, int k) {
        int n = s.size();
        int m = t.size();
        int i = 0;
    
        while (i < n && i < m && s[i] == t[i]) {
            i++;
        }
    
        int opsNeeded = (n - i) + (m - i);
    
        if (opsNeeded > k) {
            return "No";
        }
        else if ((k - opsNeeded) % 2 == 0 || k >= n + m) {
            return "Yes";
        }
        else {
            return "No";
        }
    }
    
  • + 1 comment

    The test case 7 is wrong

    s=aaaaaaaaaa t=aaaaa k=7

    You only need 5 delete operations on s to convert t

    But the test case expect "Yes"

  • + 0 comments
    def appendAndDelete(s, t, k):
        prefix_count = 0
        len_s = len(s)
        len_t = len(t)
        while prefix_count < len(t):
            if prefix_count > (len_s - 1) or s[prefix_count] != t[prefix_count]:
                break
            else:
                prefix_count += 1
        
        delete_required = len_s - prefix_count
        addition_required = len_t - prefix_count
        total_ops_required = delete_required + addition_required
        if k >= (len_s + len_t):
            return "Yes"
            
        if k >= total_ops_required and (k - total_ops_required) % 2 == 0:
            return "Yes"
            
        return "No"
    
  • + 1 comment

    There is a testcase 5 in which we have: y yu 2 Should'nt the expected output be 'Yes'? because the operation can be performed according to me.